Function to read find title of an excel column

4 ビュー (過去 30 日間)
Michael
Michael 2011 年 6 月 18 日
回答済み: Ahmed Elsherif 2018 年 11 月 22 日
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 Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by