필터 지우기
필터 지우기

Function to read find title of an excel column

조회 수: 10 (최근 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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by