Excel reading all columns with a loop

조회 수: 5 (최근 30일)
Benedikt Skurk
Benedikt Skurk 2021년 2월 8일
답변: Mathieu NOE 2021년 2월 9일
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에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by