selecting columns by their name

7 views (last 30 days)
Lolak
Lolak on 30 Apr 2016
Edited: Image Analyst on 30 Apr 2016
Hi, I use the attached test.xlsx file as an example to explain my problem. Assume that I have the test.xlsx in excel and I want to use this to do operations on its columns. But this operation just needs to be performed on specific columns. For example I need my code to first select the numerical values in columns that have "AUD AUD_EOD" with "Zero 1d" and "AUD AUD_EOD" with "Zero9m" in their titles to be saved in a matrix A. Then do the same thing for columns with "CAD CAD_EOD" with "Zero 1d" and "CAD CAD_EOD" with "Zero9m" in their titles and save them in matrix B and then do the operation on matrix A and B. So my problems is that, how can I do this selection without using for loops. Again as I said the test.xlxs is just a sample and I basically have a huge file that this needs to be done for it.
I appreciate any comments to solve this problem.
Thanks,

Answers (1)

Image Analyst
Image Analyst on 30 Apr 2016
Edited: Image Analyst on 30 Apr 2016
It's easy if you use tables. Use readtable() to read in the workbook
t = readtable('test.xlsx', 'Range', 'B4:L9')
oneColumn = t.AUDAUD_EOD % Get just this one column with this name

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!