Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: Linear Algebra Using Matlab
Description: Notes demonsrating how to solve linear algebra problems using Matlab.
Description: Notes demonsrating how to solve linear algebra problems using Matlab.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
LEARNING LINEAR ALGEBRA USING
MATLAB
1
Advice
• Nobody could or would want to know
everything about MATLAB
...
• Use the Help files
...
• Be prepared for frustraEon, but if you need
MATLAB it is worth the frustra?on
...
Prac?ce
more
...
A vector will have only one row or one column
...
A row vector is entered row-wise with
consecutive elements of a row separated by a
space or a comma
...
a=[1,2,3,4,6,4,3,4,5] or
a=[1 2 3 4 6 4 3 4 5]
Answer is:
a=
1
2
3
4
6
4
3
4
5
4
Column Vector
Elements in a column vector are separated
by a semicolons
...
Example:
v=[1;3;5;6]
Answer:
v=
1
3
5
6
5
• Now let us add 2 to each element of ‘a’ vector
and store the result in a new vector ‘b’
...
The enEre matrix must be enclosed within square
brackets
...
0000
0
...
0000i 5
...
0000i
8
Con?nua?on
• If it is not possible to type the enEre input on the
same line, then use three consecu?ve periods
(…) to signal conEnuaEon and conEnue the input
on the next line
...
MATLAB Command
Answer
A=
1
5
A=[1 3 4;5 10
...
• For a complex matrix C, Ct=C’ produces the
conjugate transpose
Find the transpose of the following matrices
using MATLAB
11
MATLAB Command:
A=[1 2 3;7 8 9;10 11 12];
B=A'
Answer
B=
1 7
2 8
3 9
10
11
12
MATLAB Command
C=[12 3 4-8*i;5*i 10 15];
Ct=C'
Answer
Ct =
12
...
0000i
3
...
0000
4
...
0000i 15
...
* operator
...
*B
2/11/10
ANSWER
C=
1 4 0
4 25 -10
0 -10 1
Soori Prashant Kumar
14
Inverse of a Matrix
MATLAB Command
A=[5 -1;10 -1];
B=inv(A)
Output
B=
-0
...
0000
0
...
0000
15
To prove that Inverse of a matrix ‘A’ multiplied
by ‘A’ matrix gives Identity Matrix
MATLAB Command
A=[5 -1;10 -1];
B=inv(A);
I=inv(A)*A
Output
I=
1 0
0 1
16
Exponen?a?on
MATLAB Command:
A=[1 0 2;2 4 5;1 2 2];
B=A^3
Output:
B=
17 28 38
101 172 228
47 80 106
17
More operaEons
• diag(v) Generates diagonal matrix with vector
‘v’ on the diagonal
...
• diag(A,1) extracts the first upper off‐diagonal
vector of matrix A
18
MATLAB Command
B=[1 1 1 0 0;1 1 1 0 0;1 1 1 0 0;0 0 0 4 0;0 0 0 0 4]
diag(B)‘
Output
B=
1 1
1 1
1 1
0 0
0 0
ans =
1 1
1
1
1
0
0
0
0
0
4
0
0
0
0
0
4
1
4
4
19
MATLAB Command
B=[1 1 1 0 0;1 1 1 0 0;1 1 1 0 0;0 0 0 4 0;0 0 0 0 4]
diag(B,1)‘
B=
1
1
1
0
0
ans =
1
1
1
1
0
0
1
1
1
0
0
0
0
0
4
0
1
0
0
0
0
0
0
4
20
Watch and understand
MATLAB Command:
d=[1 5 7 9];
d1=[2 2 2];
d2=[-1 -1];
D=diag(d)+diag(d1,1)+diag(d2,-2)
D=
1
0
-1
0
2
5
0
-1
0
2
7
0
0
0
2
9
21
To find the determinant
Find the determinant of A
MATLAB Command
A=[1 0 1;0 2 4;3 3 0];
det(A)
ans =
-18
22
To find the eigenvalue
Find the eigenvalue of A
MATLAB Command
A=[2 -2;-2 5];
eig(A)
ans =
1
6
23
To find the coefficients of the characteris?c polynomial
• The “poly” funcEon generates a vector containing the
coefficients of the characterisEc polynomial
...
These are actually the eigenvalues of the
given matrix
...
8944 -0
...
4472 0
...
7417
26
More Stuff
– help svd
– help QR
– help LU
– help rref
– help rcond
– help cond
27
Title: Linear Algebra Using Matlab
Description: Notes demonsrating how to solve linear algebra problems using Matlab.
Description: Notes demonsrating how to solve linear algebra problems using Matlab.