calculate mean af cell

조회 수: 1 (최근 30일)
fereshte
fereshte 2014년 7월 12일
편집: fereshte 2014년 7월 13일
I have a cell with 30 rows., In each row there are 39 columns. Every ten folders belong to one person. For each column I want to calculate the average value for the ten folders and give this value instead of 10 different amounts. then do it for folders from 11 to 20 and 21 to 30.
  댓글 수: 7
Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 13일
편집: Azzi Abdelmalek 2014년 7월 13일
Each 10 rows from what?
fereshte
fereshte 2014년 7월 13일
rows from 1 to 10 is person one.from 11 to 20 is person two.and 21 to 30 is person three.i want use this cell for person identification

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 12일
편집: Azzi Abdelmalek 2014년 7월 13일
clear out
m1=reshape(1:30,10,3);
for k=1:3
m=data_matrix(m1(:,k));
f=num2cell(reshape([m{:}],39,[])',1);
out{1,k}=arrayfun(@(x) mean(cell2mat(f{x}'),2),1:39,'un',0);
end
out=repmat(out,10,1)
out=out(:)
  댓글 수: 9
Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 13일
Look at edited answer
fereshte
fereshte 2014년 7월 13일
편집: fereshte 2014년 7월 13일
thank you so much.

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

추가 답변 (1개)

Roger Stafford
Roger Stafford 2014년 7월 12일
If your "cell" is an ordinary 'double' 30 x 39 array, A, do this:
B = [mean(A(1:10,:),1);mean(A(11:20,:),1);mean(A(21:30,:),1)];
or else this:
B = reshape(mean(reshape(A,10,[]),1),3,[]);
Either method should work.
  댓글 수: 1
fereshte
fereshte 2014년 7월 12일
편집: fereshte 2014년 7월 12일
i dont write this code.please help me :( my cell attached above its 30*1 cell.then in each cell there are 39 features that they are numerical. name of cell is data_all.mat. what write instead of A?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by