finding mean and storing in a new cell

Hi,
I have the following data series:
-0.01342
-0.00200
0.04210
0.01854
0.07183
0.01343
0.07494
0.02699
-0.08492
0.02870
-0.01921
-0.07003
-0.07477
0.03745
-0.03381
0.01330
0.02992
-0.03780
-0.00544
0.04873
-0.00489
-0.01814
0.00560
0.00055
What I want to do is that I wish to find average of the first three numbers(cells) and then keep it in a new series' s first cell. Then average the next three and keep it in the second cell of the new series and so on.
Help needed.
Regards,
AMD.

댓글 수: 3

Try this A=[-0.01342 -0.00200 0.04210 0.01854 0.07183 0.01343 0.07494 0.02699 -0.08492 0.02870 -0.01921 -0.07003 -0.07477 0.03745 -0.03381 0.01330 0.02992 -0.03780 -0.00544 0.04873 -0.00489 -0.01814 0.00560 0.00055]
newCellMean=zeros((numel(A)/3),1);
for i=1:ceil(numel(A)/3)
if i==ceil(numel(A)/3)
newCellMean(i,1)=mean(A((((3*i)-2)):end,1));
else
newCellMean(i,1)=mean(A((((3*i)-2)):(3*i),1));
end
end
Matt Fig
Matt Fig 2012년 9월 13일
When you say 'cells' do you mean elements? In MATLAB a cell array is a specific thing, quite distinct from a numerical array.
ARS
ARS 2012년 9월 13일
Hi Matt,
By cell I here mean a data instance (excel cell). Not the cell array you are talking about.
Regards,
Ahamd.

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 9월 13일

1 개 추천

Provided that your data is an exact multiple of 3 long:
mean( reshape(YourData, 3, []) )

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time Series Events에 대해 자세히 알아보기

제품

태그

질문:

ARS
2012년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by