Plot average monthly flow from Jan-Dec for 'x' number of yrs on one plot using the provided data
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello MATLAB Community,
I want to plot the average monthly values from Jan-Dec for 'x' number of years on the same plot. I was able to calculate the average using groupsummary. How can I use the isbetween or any other function to separate out those years in varaible 'yr' from the Mean table and plot them in single plot. I have also attached the sample output which I am expecting to get.
clc
clear
close all
data = readtable('Test.xlsx');
Mean = groupsummary(data,'Date','month','mean');
yr=[1977,1988,1989,1991,2003]
0 Commenti
Risposta accettata
Cris LaPierre
il 29 Lug 2022
Group by year and monthofyear. Then you can use ismember and reshape to identify and organize the data in a manner that will allow you to generate the desired plot.
file = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1082210/TEST%20(1).xlsx';
data = readtable(file);
Mean = groupsummary(data,{'Date_Time','Date_Time'},{'year','monthofyear'},'mean','WaterLevel')
yrs = [1977,1988,1989,1991,2003];
yr=ismember(str2double(string(Mean.year_Date_Time)),yrs);
x = reshape(Mean.monthofyear_Date_Time(yr),12,[]);
y = reshape(Mean.mean_WaterLevel(yr),12,[]);
plot(x,y)
xticklabels({'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})
legend(string(yrs))
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!