-1

I have a cellarray A of dimension 64x8 with elements in the following dimension,

520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double
520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double
520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double    520x1 double
...................

Now I need to take MEAN across the 8 rows in each column, so that i will get just one 520X1 cell per row.

so, after applying mean across rows, my output should be something like,

520x1 double
520x1 double
520x1 double
520x1 double
............

So, my output would be a 64x1 cell array transformed from 64x8.

i tried with doing this with the following command,

avgCell = {mean(cat(3,C{:}),3)}

But, it gives 1X1 cell array with just one cell of dimension 520X1.

Kindly correct me, and suggest me if there is any function to deal with this. and also let me know if i need a loop to do this?

  • Mh... if you calculate a row wise mean, how are you actually expecting it to be a 520x1 vector? – Tommaso Belluzzo Dec 28 '17 at 14:54
  • If your vectors are always going to be uniform then you'd be better off with a 3D array where each row of the current cell array is a 2D slice. – sco1 Dec 28 '17 at 15:02
  • 1
    A reevaluation of your data storage & processing methodology may be prudent anyway, given that your question history consists solely of progressing issues with addressing data crammed into cell arrays. – sco1 Dec 28 '17 at 15:11
  • Sorry @TommasoBelluzzo, its column wise – Deepak Eevil Personified Dec 28 '17 at 15:50

1 Answers1

0
% Create sample data...

A = cell(64,8);

for i = 1:64
    for j = 1:8
        A{i,j} = rand(520,1);
    end
end

% Calculate column-wise means...

B = mean(cell2mat(A),2);

% Reshape the result into a cell array...

C = mat2cell(B,repmat(520,64,1),1);
Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98