selecting columns by their name

조회 수: 7 (최근 30일)
Lolak
Lolak 2016년 4월 30일
편집: Image Analyst 2016년 4월 30일
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,

답변 (1개)

Image Analyst
Image Analyst 2016년 4월 30일
편집: Image Analyst 2016년 4월 30일
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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by