How can i create a descriptive statistics table for columns

14 ビュー (過去 30 日間)
Stefano Döring
Stefano Döring 2018 年 4 月 7 日
移動済み: Stephen23 2025 年 7 月 11 日
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!

採用された回答

David Fletcher
David Fletcher 2018 年 4 月 7 日
The default behavior for most of the statistical function is for column-wise operation and since that is what you want you can just apply them to your data matrix. So, if you want to collate the results together in a matrix:
results=[mean(data)' max(data)' std(data)']
If you specically want a table then:
dummyData=randi(10,15,10)
results=table()
results.Mean=mean(dummyData)'
results.Max=max(dummyData)'
results.Std_dev=std(dummyData)'
results =
10×3 table
Mean Max Std_dev
______ ___ _______
5.6 10 3.4184
5.0667 9 2.7894
4.6667 10 3.2878
6.0667 10 2.7894
5.2 10 2.8082
5.0667 10 2.5765
5 10 2.9032
5.6 10 2.7464
5.5333 10 2.8502
5.2 9 2.5967
  1 件のコメント
Stefano Döring
Stefano Döring 2018 年 4 月 9 日
Thank you very much! This helped alot!

サインインしてコメントする。

その他の回答 (2 件)

Peter Perkins
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.

Jennifer Rebbin
Jennifer Rebbin 2025 年 7 月 10 日
移動済み: Stephen23 2025 年 7 月 11 日
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"])
A: 15×10 double Mean 0.5868 0.4791 0.4498 0.4893 0.3601 0.4134 0.4774 0.4449 0.4877 0.4195 Max 0.9065 0.8000 0.9323 0.9274 0.9326 0.9495 0.8417 0.9956 0.9812 0.8821 Std 0.1783 0.2277 0.2968 0.2769 0.2859 0.3100 0.2320 0.3047 0.2570 0.2650

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by