how to get the mean for specific rows number of one columns
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hazem Mahmoud
am 21 Feb. 2021
Kommentiert: Hazem Mahmoud
am 22 Feb. 2021
1 5
2 7
3 9
1 9
2 7
3 9
if column 1 is month how to get the mean of January only which is 5 and 9 then feb which is 7 and 7 mean then march 9 and 9 mean
Thanks in advance
0 Kommentare
Akzeptierte Antwort
Paul Hoffrichter
am 22 Feb. 2021
M = [ ...
1 5
2 7
3 9
1 9
2 7
3 9
];
T = array2table( M, ...
'VariableNames',{'Month','Rainfall'});
disp('Table');
disp(T)
Tmean = varfun(@mean,T,'InputVariables','Rainfall',...
'GroupingVariables','Month');
disp('Mean of Rainfall by Month')
disp(Tmean)
Output
Table
Month Rainfall
_____ ________
1 5
2 7
3 9
1 9
2 7
3 9
Mean of Rainfall by Month
Month GroupCount mean_Rainfall
_____ __________ _____________
1 2 7
2 2 7
3 2 9
5 Kommentare
Paul Hoffrichter
am 22 Feb. 2021
Is this what you want?
plot(Tmean.Month, Tmean.mean_Rainfall, '-bo')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!