To calculate the standard deviation of a matrix in MATLAB, you can use the std() function. By default, this function operates column-wise, so to find the standard deviation for the entire matrix, you can pass the matrix to std() as a vector (using the (:) notation to flatten the matrix).
main.m48 chars3 lines
Alternatively, you can specify the dim parameter to operate along a different dimension. For example, to find the standard deviation of each row, you would use dim=2:
main.m50 chars3 lines
Note that the 0 parameter indicates that the calculation should use the default normalization (dividing by N rather than N-1).
gistlibby LogSnag