Zen and the Art of MatLab Damian Gordon
Hard work done by : Daphne Gilbert & Susan Lazarus
Introduction to MatLab MatLab is an interactive, matrix-based system for numeric computation and visualisation MATrix LABoratory Used in image processing, image synthesis, engineering simulation, etc.
References “Mastering MatLab” Duane Hanselman, Bruce Littlefield “The MatLab Primer” at/mat.html “The MatLab FAQ” -faq.html
Printed Circuit Board
Specific Bond Selected
Bond Shape Estimated
MATLAB Command Window To get started, type one of these: helpwin, helpdesk, or demo. For product information, type tour or visit » » help HELP topics:
Creating Variables >> varname = 12 varname = 12 >> SS = 56; N = 4; Tot_Num = SS + N Tot_Num = 60
Operations +Addition -Subtraction *Multiplication ^Power \ Division / Division Add vars Subtract vars Multiplication Raise to the power Divide vars (A div B) Divide vars (B div A)
Creating Complex Numbers >> 3 + 2i >> sqrt(9) + sin(0.5)*j ans = i Num = sqrt(9) + sin(0.5)*j real(Num) imag(Num)
Entering Matrices (1) >> A = [1 2 3; 4 5 6; 7 8 9] OR >> A = [ ]
Entering Matrices (2) To create an NxM zero-filled matrix >> zeros(N,M) To create a NxN zero-filled matrix >> zeros(N) To create an NxM one-filled matrix >> ones(N,M) To create a NxN one-filled matrix >> ones(N)
Entering Matrices (3) To create an NxM randomly-filled matrix (which is uniformly distributed) >> rand(N,M) To create an NxM randomly-filled matrix (which is normally distributed) >> randn(N,M)
Complex Matrices To enter a complex matrix, you may do it in one of two ways : >> A = [1 2; 3 4] + i*[5 6;7 8] OR >> A = [1+5i 2+6i; 3+7i 4+8i]
MATLAB Command Window » who Your variables are: a b c » whos Name Size Bytes Class a 8x8 512 double array b 9x9 648 double array c 9x9 648 double array Grand total is 226 elements using 1808 bytes
Matrix Addition » A = [ ; ; 3 3 3] » B = [3 3 3 ; ; ] » A + B ans =
Matrix Subtraction » A = [ ; ; 3 3 3] » B = [3 3 3 ; ; ] » B - A ans = 2 2 2
Matrix Multiplication » A = [ ; ; 3 3 3] » B = [3 3 3 ; ; ] » A * B ans =
Matrix - Power » A ^ 2 ans = » A ^ 3 ans =
Matrix Transpose A = » A' ans = 1 2 3
Matrix Division Left Division \ x = A\B (is A*x=B) >> A = rand(4) >> B = rand(4) >> C = A \ B => A * C = B Right Division / x=A/B (is x*A=B) >> A = rand(4) >> B = rand(4) >> C = A / B => C * A = B
Matrix Operations +Addition -Subtraction *Multiplication ^Power ‘Conjugate Transpose \ Left Division /Right Division Add matrices Subtract matrices Matrix Multiplication Raise to the power Get transpose x = A\B (is A*x=B) x=A/B (is x*A=B)