calculate mean and max values using the groupsummary command
9 views (last 30 days)
Show older comments
Hello everyone,
As you can see from the attached picture I have successfully imported a large table matrix (T2) that shows certain wave motion variables for several years (hourly). I am trying to study the mean and maximum yearly values using "groupsummary" ( more or less like this: T22 = groupsummary(T2,"Var1","year",'mean'); ) but the command doesn't work and I am pretty sure it is because the 3rd and 6th columns have values between apostrophes ( 'x' ). I have run the same command in other situations and it works perfectly fine so I guess that the solution would be to get rid of those apostrophes..
Is there a smart way to do that? Of course I cannot do it manually since the matrix is extremely large.
Thank you in advance for your help and patience.
6 Comments
Simon Chan
on 7 Sep 2022
Seems your data can be retrieved by using readtable without any issues. Below shows the data from your attached csv file on year 2004.
On the other hand, since your data are already separated on a yearly basis. There is no need to use function groupsummary to determine the mean and maximum values for each year. You can just use function mean or max directly.
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1117965/Wave%20Data%202004_Open%20Data_WLC.csv','VariableNamingRule','preserve');
head(data,5)
Answers (1)
Seth Furman
on 12 Sep 2022
tt = readtimetable("https://in.mathworks.com/matlabcentral/answers/uploaded_files/1117915/Wave%20Data%201994_Open%20Data_WLC.csv","VariableNamingRule","preserve")
retime(tt(:,vartype("numeric")),"yearly","mean")
retime(tt(:,vartype("numeric")),"yearly","max")
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices 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!