Excel reading all columns with a loop
1 view (last 30 days)
Show older comments
Hello,
i got a question, and i really need some help cause i am pretty new to matlab.
From the excel sheet i attached i want to read each column so from Monday to Saturday and plot each Day on the y-Axis and on the X-Axis should be the time in the first column for every plot.
So i know how to read the whole excel sheet with xlsread but i dont know how ot build the loop for the reading every column separately.
Could u maybe help me with the problem?
Best Regards
0 Comments
Answers (1)
Mathieu NOE
on 9 Feb 2021
hello again...
based on my previous suggestion, this will do the trick :
[filename, pathname] = uigetfile('*.xlsx', 'Bitte Datei aussuchen'); % Leitungen_Auslastung.xlsx
[numericData, ~, rawData] = xlsread(fullfile(pathname, filename));
headers = rawData(1,:); % variable names
comments = rawData(2,:); % comments names / units
Y_legends= headers(2:end);
% replace underscore with blanks for legend strings
Y_legends2 = strrep(Y_legends,'_',' ');
[samples,nrows] = size(numericData);
y = numericData; % rows B and beyong (select rows with N if needed)
date_data = rawData(2:end,1);
dn=datetime(date_data,'InputFormat','yyyy.MM.dd HH.mm.ss');
figure(1),plot(dn,y);
xlabel('Time (s)')
ylabel(' Data');
legend(Y_legends2);
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!