m(:) mean in matlab

In MATLAB, the m(:) expression is used to reshape a matrix m to a column vector.

For example, consider the following matrix:

main.m
m = [1 2; 3 4; 5 6]; 
22 chars
2 lines

Using m(:) yields the following column vector:

main.m
[1; 3; 5; 2; 4; 6]
19 chars
2 lines

This can be useful when performing certain matrix operations, such as matrix multiplication or inversion.

related categories

gistlibby LogSnag