Calculate statistical parameters from certain rows of a matrix

조회 수: 1 (최근 30일)
BoIs
BoIs 2019년 8월 12일
댓글: BoIs 2019년 8월 12일
I have data of days and temperature in specific intervals recorded through out that particular day: eg
Day Temp
1 24
1 24.5
1 24.5
2 25
2 25
2 25
3 25.5
3 25.5
3 25.5
and so on for many number of days through. If I want to take the mean of all the temperature values from only day 1, how would I go about doing this using indexing?

채택된 답변

madhan ravi
madhan ravi 2019년 8월 12일
Wanted=splitapply(@mean,x(:,2),findgroups(x(:,1))) % x(:,1) is Day and x(:,2) is Temperature
% or if you're using version prior to 2015b then:
Wanted=accumarray(Day,Temperature,[],@mean);
For only one day it’s simply:
day = 1;
mean(Temperature(Day==day))

추가 답변 (1개)

Jos (10584)
Jos (10584) 2019년 8월 12일
help grpstats
help accumarray

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by