Extracting data from excel

2 次查看(过去 30 天)
Salaijobhaka
Salaijobhaka 2017-4-17
回答: dpb 2017-4-17
Hi I would like to extract data from a column in which the second row contains string "P5" (Figure attached). One way is to use "xlsread('filepath/data.csv','DQ:DQ')". In this case one need to look at corresponding excel column index, i.e., "DQ". Is there a way in which one can extract data without looking at excel column index but using the string index, i.e., "P4" instead ?

回答(1 个)

dpb
dpb 2017-4-17
With "pure" Matlab-supplied functions, no. You would have to do it indirectly, reading the header row then finding the desired string location therein. As xlsread is quite slow already, almost surely at least as fast to simply just read the full sheet and save what you're interested in.
I'm sure it's also possible with COM to write specific commands but that becomes an Excel VBA syntax problem, not Matlab once the automation server is created.

Community Treasure Hunt

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

Start Hunting!

Translated by