MATLAB: Working with multiple matrix avoiding “for”

multiple matrix for

I have 253 vertically pasted matrix of size 221×431 (final dimensiĆ³n of 55913×431). I would like to calculate the coefficient of variation (standard deviation/mean) of each element of the matrix, obtaining a final matrix of size 221×431. I have the following code which works but I would like to know if I could do it in a more simple and efficient way without using "for". Could you give me any suggestion? thank you for your help.
% b -> start matrix, size (55913,431)
for col = 1 : 431
for r = 1 : 221
m =b(r: 221 : 55913,col);
variation(r,col)= std(m)/mean(m);
end
end

Best Answer

b=rand(55913,431);% b is your matrix
a=permute(reshape(b',431,221,[]),[2 1 3]);
variation=std(a,0,3)./mean(a,3);
I tested the two methods speed
With the for loop : Elapsed time is 7.797265 seconds.
Without loop : Elapsed time is 0.479849 seconds.