필터 지우기
필터 지우기

Single function like stepinfo but for general stats?

조회 수: 1 (최근 30일)
matlabuser12
matlabuser12 2015년 3월 12일
댓글: Brendan Hamm 2015년 3월 13일
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
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
matlabuser12 2015년 3월 12일
편집: matlabuser12 2015년 3월 12일
I had the for loop because I wanted to create a structure with individual breakdowns of this info. So my data I am parsing to grpstats, is a structure of data names, each with 5 columns in it. I wanted the same structure for stats. how would i do that? data in my case looks like grpstats(data(i).datanew,[],...) sorry i did not mention this. would i just write stat(i).means, stat(i).stds, etc. instead?
Brendan Hamm
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by