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 月 12 日
What do you mean by every ten folders?
fereshte
fereshte 2014 年 7 月 12 日
every 10 folders are including of 39 features.i want get mean of each features for 10 folders and put it instead relevant feature.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 12 日
What do you mean by folder?
Image Analyst
Image Analyst 2014 年 7 月 12 日
By "folder" do you mean "row"????
fereshte
fereshte 2014 年 7 月 13 日
sorry not folder.cell mat contain 30 rows.and each row have 39 features. each 10 row Owned by an individual.but attribute values are different in 10 rowa for each person.for this reason,i want to find the mean values in each 10 rows and put them instead of the original values.
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 日

0 投票

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 件のコメント

fereshte
fereshte 2014 年 7 月 12 日
i write this: load('data_all.mat')
out=cellfun(@(x) mean(reshape(x,10,3)),data_matrix,'un',0)
but get error: To RESHAPE the number of elements must not change.
Error in ==> @(x)mean(reshape(x,10,3))
Error in ==> Untitled3 at 2 out=cellfun(@(x) mean(reshape(x,10,3)),data_matrix,'un',0)
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 13 日
Look at edited answer
fereshte
fereshte 2014 年 7 月 13 日
in out must be 30 rows not 3 rows!!each 10 rows is similar togeather.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 13 日
Then what mean do you want?
fereshte
fereshte 2014 年 7 月 13 日
each new 10 rows are mean of inital ten rows.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 13 日
This is not clear
fereshte
fereshte 2014 年 7 月 13 日
i want do train and test with this data.in cell.mat there are 30 rows that each 10 rows Are related to one person but with diffrenet values.For every ten lines must be do mean that you do it perfect. but this mean value should be replaced in 10 rows instead of previous numbers.for 11 to 20 and 21 ta 30 too.output must have 30 rows. that each 10 rows are similar and contain mean valuse
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 日

1 投票

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?

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2014 年 7 月 12 日

編集済み:

2014 年 7 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by