Selecting columns from an Excel file
35 views (last 30 days)
Show older comments
Shahar ben ezra
on 15 Dec 2020
Commented: Shahar ben ezra
on 16 Dec 2020
Hi
When I read an excel file by "readtable" I get the following file as an example
I am interested in getting the frequency range of 102-105 MHz only
How can I cut the file?
Thanks:)
** The original file contains a lot of columns so I am interested in entering the frequency range
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/462400/image.png)
0 Comments
Accepted Answer
Cris LaPierre
on 16 Dec 2020
Edited: Cris LaPierre
on 16 Dec 2020
Use detectimportoptions and set the opts.SelectedVariableNames to be the variables (columns) you want to import. You can see several examples here. Here is another example from the readtable documenation page.
If your file contains a header row, those names can become the variable names. However, your specific request - having MATLAB figure out which columns to import by just entering a frequency range - is not native functionality. This is not to say you couldn't implement something, but it's on you to create the code to do that.
More Answers (1)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!