Plot multiple irradiances as one average

I am plotting the hourly irradiances of every month, but now I need to plot the hourly average irradiance over the month. I don't know how to do it - I'm very new to MATLAB. Any help would be appreciated :)

Answers (2)

You haven't shared your data, which will impact how this can be done, but I suggest looking into groupsummary. In particular, if your time data in a datetime, you can set the groupbin option to 'month' and your method to 'mean', which will create an output table with the hourly average of the indicated 'datavars' table variables.
Perhaps it would look something like this. Untested, so just for show.
data = readtable(...)
data.Date = datetime(data.YEAR,data.MO,data.DY,data.HOUR,zeros(heigh(data),1),zeros(height(data),1));
Mavg_data = groupsummary(data,"Date","month","mean","irradiance")
plot(Mavg_data.month_data,Mavg_data.mean_irradiance)
You might look into these functions: groupsummary, grpstats, or splitapply
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Products

Release

R2022b

Tags

Asked:

on 4 Apr 2023

Answered:

on 4 Apr 2023

Community Treasure Hunt

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

Start Hunting!