Introduction To MATLAB: Lecturer: Cik Sitinoor Adeib Binti Idris Room: Level 5 CONTACT NUMBER: 03-5543 6362
Introduction To MATLAB: Lecturer: Cik Sitinoor Adeib Binti Idris Room: Level 5 CONTACT NUMBER: 03-5543 6362
Produces
a=
3
The output means the element of x in the
first row and the third column is assigned to
the variable a.
REMEMBER! When using this form of
expression that the ROW NUMBER is referred
to FIRST and the COLUMN NUMBER SECOND
Example 3
>> x ( 3 , 3 ) = x ( 1 , 3 )
Returns
x=
1 2 3
4 5 6
7 8 3
When referencing a vector, i.e. a matrix with
a single column or row only a single figure is
required in the parentheses.
If required further columns and/or rows can
be appended to a matrix with relative ease.
For example if we define a new matrix y as
follows:
>> y = [ 10 11 12 ]
Then enter the following command:
>> x = [ x ; y ]
b) >> x = [ 1 0 2 ] ‘
2) Matrix Arithmetic
= is performed exactly as you would expect
= for example:
>> c = a + b
>> c = a * b
It is possible to multiply, divide, add and
substract matrices by scalars (i.e. single
numbers).
For example:
>> y = x * 2
>> y = x - 1
Matrix Division
1) Right division 2) Left division
= / character = \ character