Excel reading all columns with a loop

2 views (last 30 days)
Benedikt Skurk
Benedikt Skurk on 8 Feb 2021
Answered: Mathieu NOE on 9 Feb 2021
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

Answers (1)

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

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!