accumulate in multiple array

조회 수: 1 (최근 30일)
Kafayat Olayinka
Kafayat Olayinka 2019년 5월 17일
댓글: Kafayat Olayinka 2019년 5월 17일
I have:
Temperature profiles array for 5 days. such that, temp(heigth,day). however, there are multiple profile in some days which makes the number of profile equal 11.
size of temp = (3650 by 11)
size of day = (1 by 11)
day=[1,1,1,2,2,3,3,3,4,4,5].
I want to:
average temperature for every similar days
such that:
dailyday=[1,2,3,4,5]
temp=(3650 by 5)

채택된 답변

madhan ravi
madhan ravi 2019년 5월 17일
splitapply(@(x) mean(x,2),Temp,findgroups(Day))
  댓글 수: 5
madhan ravi
madhan ravi 2019년 5월 17일
편집: madhan ravi 2019년 5월 17일
C=splitapply(@(x) {mean(x,2)},Temp,findgroups(Day));
[C{:}]
%or
[~,~,c]=unique(Day);
C = accumarray(c,1:size(Temp,2),[],@(x){mean(Temp(:,x),2)});
[C{:}]
Kafayat Olayinka
Kafayat Olayinka 2019년 5월 17일
Worked perfectly. Thank you.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 5월 17일
[mean(temp(:,1:3),2), mean(temp(:,4:5)), mean(temp(:,6:8)), mean(temp(:,9:10)), temp(:,11)]
  댓글 수: 1
Kafayat Olayinka
Kafayat Olayinka 2019년 5월 17일
Thanks. How should I write the loop assuming Days are more than 5 days and each day may have multiple temperature profiles. How should I average each temp profile per day?

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by