How can i create a descriptive statistics table for columns
显示 更早的评论
Hey Guys!
My MatLab skills are pretty pretty basic and now i need your help with something, because i can't find the answer here. So i have a 15x10 data.mat where there are 10 variables with 15 values. Now i want some descreptive statistics of those variables.
The perfect solution would be a group that looks kind of like this:
Mean Max Std ...
Variable 1 x x x
Variable 2 x x x
...
Is there any way to achieve a table/group like this?
Thank you very much in advance!
采纳的回答
更多回答(2 个)
Peter Perkins
2018-4-11
Another possibility:
>> t = array2table(rand(10,5))
t =
10×5 table
Var1 Var2 Var3 Var4 Var5
________ ________ _______ ________ _________
0.69989 0.96865 0.28101 0.67612 0.78052
0.63853 0.53133 0.44009 0.28906 0.67533
0.033604 0.32515 0.52714 0.67181 0.0067153
0.068806 0.10563 0.45742 0.69514 0.60217
0.3196 0.61096 0.87537 0.067993 0.38677
0.53086 0.7788 0.51805 0.25479 0.91599
0.65445 0.42345 0.94362 0.22404 0.0011511
0.40762 0.090823 0.63771 0.66783 0.46245
0.81998 0.26647 0.95769 0.84439 0.42435
0.71836 0.15366 0.24071 0.34446 0.46092
>> t2 = varfun(@(x) [mean(x); max(x); std(x)],t)
t2 =
3×5 table
Fun_Var1 Fun_Var2 Fun_Var3 Fun_Var4 Fun_Var5
________ ________ ________ ________ ________
0.48917 0.42549 0.58788 0.47356 0.47164
0.81998 0.96865 0.95769 0.84439 0.91599
0.27434 0.29609 0.26046 0.26458 0.29787
>> t2.Properties.RowNames = {'mean' 'max' 'std'}
t2 =
3×5 table
Fun_Var1 Fun_Var2 Fun_Var3 Fun_Var4 Fun_Var5
________ ________ ________ ________ ________
mean 0.48917 0.42549 0.58788 0.47356 0.47164
max 0.81998 0.96865 0.95769 0.84439 0.91599
std 0.27434 0.29609 0.26046 0.26458 0.29787
>> t2.Properties.VariableNames = extractAfter(t2.Properties.VariableNames,'Fun_')
t2 =
3×5 table
Var1 Var2 Var3 Var4 Var5
_______ _______ _______ _______ _______
mean 0.48917 0.42549 0.58788 0.47356 0.47164
max 0.81998 0.96865 0.95769 0.84439 0.91599
std 0.27434 0.29609 0.26046 0.26458 0.29787
That's the wrong orientation for what you asked. In R2018a, you could use rows2vars to "flip" it the other way 'round.
Starting in R2024b, you can use the summary function and specify the statistics to compute using the Statistics name-value argument.
A = rand(15,10);
summary(A,Statistics=["mean" "max" "std"])
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!