How to import headers from a Excel file automatically without pre-defining them in Matlab code.

Hello People,
I have question and it would be great if some one could suggest me a solution for this. Below is my code.I earlier had defined my headers under 'S' which is a comment now, Could I use a command to call my headers instead of the "if and else" Suggested by friend.
************************************************************************************************************
[filename,pathname]=uigetfile('*.xlsx');
[data,textdata,~]=xlsread(fullfile(pathname,filename));
[~,sheets]=xlsfinfo(fullfile(pathname,filename));
[Sel,v]=listdlg('PromptString','Select Desired Sheet',...
'SelectionMode','single','ListString',sheets);
[data,textdata]=xlsread(fullfile(pathname,filename),Sel);
%[data,textdata,~]=xlsread(fullfile(pathname,filename),);
header = textdata(2,:);
headerwidth = strcmp(header,'');
ll=length(headerwidth);
for kk = 1:ll
if headerwidth(kk) == 1 && chk == 0
headerlength=kk-1;
chk=1;
else
end
end
str = {'Select Labels:';'Single Selection'};
s=header(1:headerlength);
%s = {'Speed';'Flexplate';'TSS';'OSS/Axlering';'DOE';'Seat Track';'Steering Wheel'};
end

Answers (0)

Asked:

on 25 Jun 2015

Edited:

on 25 Jun 2015

Community Treasure Hunt

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

Start Hunting!