||Department of Engineering
Next: Picking sub-matrices
Up: Matrix operations
Previous: Matrix operations
A 1x1 matrix can be created using something like A=7;.
A=7:10; creates a matrix with 4 elements, namely 7, 8, 9 and 10.
A=7:0.5:10; creates a matrix with element values running from 7
to 10 with a step-size of 0.5.
] commas (or spaces) are used to put things
in rows, while semicolons (or line-breaks) put things in columns. So
b = [ 1 3 5; 2 4 6];
creates a matrix with 2 rows and 3 columns.
Matrices can contain strings - e.g. A='bat'.
There are commands to create particular types of matrices -
zeros, ones, eye, diag, rand, etc.