Single function like stepinfo but for general stats?
古いコメントを表示
I really like how stepinfo gives me the characteristics of my data in a single line. Is there a similar function that will give me general statistics? I am looking to get:
Max
Min
Mean
Median
Mode
StDev
peaks reached and peak time
回答 (1 件)
Brendan Hamm
2015 年 3 月 12 日
Yes. There is a function named grpstats in the Statistics Toolbox which allows you to get multiple statistics. This function will compute these statistics for different grouping variables, but you can use it just the same if all of your variables belong to the same group.
Example:
x = rand(100,1);
[meanX, stdX] = grpstats(x,[],{'mean','std'})
The brackets represent where you would normally pass the grouping variable, but we can omit this input in the manner I show.
4 件のコメント
matlabuser12
2015 年 3 月 12 日
Brendan Hamm
2015 年 3 月 12 日
Since data has 5 columns and the statistics functions are calculated on a column basis, so you are getting back a 5 element vector of the means. To get back each statistic you need to assign an output variable for each statistic.
[stat.means, stat.stds, stat.mins, stat.maxs, stat.numels, stat.vars] = ...
grpstats(data,[],{'mean','std','min','max','numel', 'var'})
We have no need for the for loop as we are calculating this seperately for each column anyhow. The function returns a separate vector for each stat, so we cannot explicitly assign all of the output to one variable.
matlabuser12
2015 年 3 月 12 日
編集済み: matlabuser12
2015 年 3 月 12 日
Brendan Hamm
2015 年 3 月 13 日
Yes, you will just want to make sure that on each call to grpstats you use data(:,i) so that you get the scalar value of mean, std, etc.
カテゴリ
ヘルプ センター および File Exchange で Repeated Measures and MANOVA についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!