0% found this document useful (0 votes)
3 views

Matlab Lecture 9

This document discusses matrix operations in MATLAB. It covers: 1. Appending rows and columns to matrices by using commands like [A; v] and [A u]. 2. Useful utility matrices that MATLAB provides to aid in matrix generation and manipulation. 3. Basic arithmetic operations that can be performed on matrices like addition, subtraction, multiplication, and division provided the operations are mathematically compatible. 4. The left division operator (\) in MATLAB which solves matrix equations like Ax = b by using the command x = A\b.

Uploaded by

M.Ahsan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Matlab Lecture 9

This document discusses matrix operations in MATLAB. It covers: 1. Appending rows and columns to matrices by using commands like [A; v] and [A u]. 2. Useful utility matrices that MATLAB provides to aid in matrix generation and manipulation. 3. Basic arithmetic operations that can be performed on matrices like addition, subtraction, multiplication, and division provided the operations are mathematically compatible. 4. The left division operator (\) in MATLAB which solves matrix equations like Ax = b by using the command x = A\b.

Uploaded by

M.Ahsan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Appending a row or column

• A row can be easily appended to an existing matrix provided the row


has the same length as the length of the rows of the existing matrix.
• The same thing goes for columns the command A=[A u] appends
column vector u to the column A , while A=[A; v] appends the
row vector v to the rows of A .
• A row or column of any size may be appended to a null matrix.
Utility Matrices
• To aid matrix generation and manipulation , Matlab provides many
useful utility matrices.
Matrix and Array Operations
Arithmetic Operations
• For people who are used to programming in a conventional language like
Pascal, Fortran or C, it is an absolute delight to be able to write a matrix
product as c=a*b where a is an matrix and b is an matrix.
• MATLAB allows all arithmetic operations to be carried out on matrices in
straightforward ways as long as the operations makes sense mathematically
and operations are compatible.
• + addition
• - subtraction
• * multiplication
• / division
• ^ exponentiation
A + B or A – B is valid if A and B are of same size
A*B is valid if A’s number of columns equals B’s number of rows
A/B is valid and equals for same size square matrices A and B
A^2 makes sense if A is square and equals A*A.
The Left Division
In addition to the normal right division (/), there is a left division (\) in
MATLAB. This division is used to solve a matrix equation. In particular
the command x = A\b solves the matrix equation Ax = b.
Thus A\b is almost the same as inv(A)*b but faster and more
numerically stable.
Example: Solve the following system of equations:
MATLAB Solution
Matrix equation is , ,
Array Operations
How does one get products like from two vectors and
You can do array operation i.e. operation done on element by element
basis.
For example:
Thank you so much

You might also like