Essentially, the only data objects in MATLAB are rectangular numerical
matrices. There are no restrictions
placed on the dimensions of a matrix (except
by system resources), but special meaning is sometimes attached
to
matrices (scalars) and matrices with only one row or column
(vectors). The memory required for the storage of each matrix is automatically
allocated by MATLAB.
The easiest way to enter a matrix into MATLAB is to provide an explicit list of elements enclosed in square brackets [ ]. MATLAB uses the following conventions:
A =
1.0000 2.0000 4.5000
4.0000 6.0000 5.0000
The ans =
5
It is important to realize that MATLAB distinguishes between row and column
vectors. [1 2 3] is a row vector, while [1; 2; 3] is a column
vector. Column vectors can also be created by applying
MATLAB's transpose operator
' (prime) to a row vector. For example
>> [1 2 3]'
produces
ans =
1
2
3
The transpose operator may be applied to matrices of any dimension.