How to calculate for each page STD in Matlab?

Suppose I have a A

100x200x300 matrix . The third dimension is called "page" in Matlab, and then this matrix has 300 pages.

Now I want to calculate the standard deviation on each page and get a 1x1x300 results matrix.

I can't just do

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

      

as normalization would be wrong as I think.

+3


source to share


1 answer


You need to collapse the first two dimensions into one (that is, columns) using reshape

; and then calculate 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. If you really need 1x1x300 use

result = shiftdim(result, -1);

      

+4


source







All Articles