Upcoming SlideShare
×

# Matlab practice

2,856 views

Published on

Show important commands demo
by
Zunaib Ali
uet ATD Campus

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,856
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
73
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Matlab practice

1. 1. MATLAB PracticeLesson 1: Vector Operations. (Entering vectors, transposition, multiplication.)Lesson 2: Matrix Operations: Transposes and Inverses.Lesson 3: Matrix Operations: Gaussian Elimination. (Manipulation of matrix rows and columns.)Lesson 4: Creating M-Files: The Adjoint Formula for the Matrix Inverse. (Introduces common programming commands.)Lesson 5: Cramer’s Rule. (More practice with m-ﬁles and matrix manipulation.)Lesson 6: Symmetric, Skew-Symmetric, and Orthogonal Matrices. (More practice with m-ﬁles.)Lesson 7: Vector Spaces. (Creating augmented matrices, rand() function.)Lesson 8: Gram-Schmidt Orthogonalization. (More practice with m-ﬁles.)Lesson 9: Root Finding & Graphing. (Finding roots of polynomials, graphing functions.)Lesson 10: Eigenvalues and Eigenvectors. (Using the eig() function.)Lesson 11: Eigenvalues and Eigenvectors. (More practice with m-ﬁles, rand() function.) 1
2. 2. Vector Operations.(a) Enter the row vector v = [3 2 − 7] by typing v = [3,2,-7](b) Convert v to a column vector by typing v = v’ .(c) Compute 2v by typing 2*v.   −4(d) Enter the column vector w =  0 . 6(e) Compute v + w by typing v + w .(f ) Compute the vector formed by cubing each element of w (type w.^3). The “.” before the operator causes each element of the vector to undergo the operation (see what happens if you type w^2).(g) Compute the vector formed by inverting each element of v (type 1./v).(h) Compute the product v T w (type v’*w).(i) Compute the vector u where [uj ] = [vj wj ] (type u = v.*w)(j) Sum all the elements in v (type sum(v)).(k) Create a zero column vector x ∈ R4 (type x = zeros(4,1)).(l) Create a column vector x ∈ R4 of all ones (type x = ones(4,1)).(m) Assign the values 0, 0.1, 0.2, . . . , 1 to the vector x (type x = 0:0.1:1).(n) Make x a column vector. 2
3. 3. Matrix Operations: Transposes and Inverses.   2 3 5(a) Enter the matrix A =  5 1 8  (type A=[2, 3, 5; 5, 1, 8; 12, 5, 21]). 12 5 21(b) Show the ﬁrst row of A by typing A(1,:) .(c) Let’s ﬁnd the transpose of A. Let B = AT (type B = A’).(d) Show the second column of B by typing B(:,2) .   2 5 1(e) Enter the matrix C =  3 1 5  5 8 5(f ) Find the solution y to the system Cy = v by typing y = Cv(g) Compute the product AB (type A ∗ B).(h) Create a 3 × 3 identity matrix by typing eye(3) 3
4. 4. Matrix Operations: Gaussian Elimination.   2 3 5(a) Enter the matrix A =  5 1 8  12 5 21(b) Let B = AT (type B = A’).(c) Store a copy of B in the matrix H (type H = B).(d) Reduce B to an echelon form by performing the following operations: (1) R1 → R2 − R1 (type B(1,:) = B(2,:) - B(1,:) ). (2) R2 → R2 − 3R1 (3) R3 → R3 − 5R1 (4) R2 → R2 /13 (5) R3 → R3 − 28R2(e) Transform the result of the above calculations to reduced row echelon form by performing the following additional operation: (6) R1 → R1 + 4R2(f ) Type help rref(g) Use the command rref to ﬁnd the reduced row echelon form for B (set B back to its original value by typing B = H before using the rref command).   2 5 1(h) Enter the matrix C =  3 1 5  5 8 5(i) Compute the inverse of C (type inv(C) ).(j) Enter the row vector w = [3 2 − 7].(k) Set v = wT .(l) Find the solution y to the system Cy = v using the formula y = C −1 v. 4