Plot multiple irradiances as one average
Show older comments
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)
Cris LaPierre
on 4 Apr 2023
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)
Image Analyst
on 4 Apr 2023
0 votes
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!