3

Suppose I have matrix A of 100x200x300. Third dimension is called "page" in Matlab and this matrix has 300 pages then.

Now I want to calculate standard deviation within each page and get a result matrix of 1x1x300.

I can't just do

std(std(A,0,1),0,2)

because normalization will be wrong as I think.

Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385

1 Answers1

4

You need to collapse the first two dimensions into one (i.e. into columns) using reshape; and then compute std along each column:

Ar = reshape(A, size(A,1)*size(A,2), size(A,3));
result = std(Ar);

This will give you a 1x300 vector as result. If you really need it to be 1x1x300, use

result = shiftdim(result, -1);
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147