Excel reading all columns with a loop

3 次查看(过去 30 天)
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

回答(1 个)

Mathieu NOE
Mathieu NOE 2021-2-9
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);

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by