Mathematics 726

Getting information about a matrix.

Here is how to get information about the dimensions of a vector or matrix. In the following A is an m x n matrix, x is a 1 x n row vector and y is a m x 1 column vector.
size(A,1)	  % Number of rows of A = m 
size(A,2)	  % Number of columns of A = n
size(A)		  % m  n  where A is m x n

lenght(A)	  % max(m,n)

length(x)	  % m
length(y)	  % n

Note if v is a vector (either row or column) then length(v) gives the length of v regardless of whether v is a row or column vector.
Home