Function to read find title of an excel column

9 次查看(过去 30 天)
I'm looking for a way to identify a specific column in an excel document based on the header of the column.
I have documents with a bunch of columns of data with different titles in different orders. I want to pick out the column with a specific title and make a matrix out of the data in that column. (I can't just use the number of the column because the order varies depending on the document)
Do you know any function that can help with that?
Thanks!

采纳的回答

Oleg Komarov
Oleg Komarov 2011-6-18
Import the excel sheet:
[data, text] = xlsread(...);
Now, use:
idx = strcmpi(text(1,:),'HeaderIamLookingFor')
data(:,idx)

更多回答(1 个)

Ahmed Elsherif
Ahmed Elsherif 2018-11-22
Hi,
I tried this but I got a wrong value. I typed a certain header name but I got the value under a different header!
Would you please tell me why this happens?
With the code below, I got the value under another header ('Start ch.')
Thanks in advance
handles.fileName = uigetfile ('.xlsx')
[data, text] = xlsread('LT2MELT');
r = strcmpi(text(1,:),'Zero_Chann.')
k=data(:,r);
set(handles.edit40,'string', k);

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by