how do i get the average line graph

Hello! i am quite new to matlab here! been stuck on this problem for a few days now, but here is my code. Basically i have a folder with mutiple excel file each filled with data. i am trying to get the plot the average line graph only.
%loop through selected ".xls" files
[file_list,path_n]=uigetfile(".xls","Grab files fo half hourly demand",'Multiselect','on');
if iscell(file_list)==0
file_list={file_list};
end
%call function
plotdata = selecteddata(path_n,file_list);
%function
function plotdata = selecteddata(path_n, file_list)
Months = ["Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"];
for k= 1:length(Months)
Months_idx = contains(file_list, Months(k));
B =[file_list(Months_idx)];
plotdata=figure;
for i=1:length(B)
filename=B{i};
data_in=xlsread([path_n filename]);
mon=data_in(:,1);
tue=data_in(:,4);
wed=data_in(:,7);
thur=data_in(:,10);
fri=data_in(:,13);
sat=data_in(:,16);
sun=data_in(:,19);
time = hours(0.5): hours(0.5):hours(24);
hold on
plot(time,mon,time,tue,time,wed,time,thur,time,fri,time,sat,time,sun)
legend('mon','tue','wed','thur','fri','sat','sun')
title(B)
end
end
end
Currently this is the output. Help would be greatly appreicated!

Respuestas (1)

Star Strider
Star Strider el 2 de Oct. de 2021
I do not have your data, however since they all have the same number of elements as ‘time’ and so can be assumed to be equal length vectors, one option would be —
alldays{k,i} = cat(2, mon,tue,wed,thur,fri,sat,sun);
I would put that just before the ‘time’ assignment. Calculate and plot the mean (and perhaps other) values across dimension 2 at the appropriate place in your code.
I am not certain what the code does, so it may be necessary to change the cell array subscript to produce the desired result.
.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 2 de Oct. de 2021

Respondida:

el 2 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by