b = [ 3 ; 2 ; 9] b = 3 2 9 Big = [A A'] Big = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 size(B) {Undefined function or variable 'B'.} size(Big) ans = 3 6 row2part=Big(2,2:4) row2part = 5 6 2 % take out entire row row3=Big(3,:) row3 = 7 8 9 3 6 9 row3=Big(3,1:6) row3 = 7 8 9 3 6 9 row3=Big(3,2:6) row3 = 8 9 3 6 9 row3=Big(3,2:end) row3 = 8 9 3 6 9 Big Big = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 col4=Big(:,4) col4 = 1 2 3 col345=Big(:,3:5) col345 = 3 1 0 6 2 5 9 3 6 % delete column 4 AT=A' AT = 1 0 7 2 5 8 3 6 9 AT(:,2)=[] AT = 1 7 2 8 3 9 % special matrices Z=zeros(3) Z = 0 0 0 0 0 0 0 0 0 Big Big = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 Big+At {Undefined function or variable 'At'.} Big+AT {Matrix dimensions must agree.} Z=zeros(3,6) Z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Z=zeros(size(B)) {Undefined function or variable 'B'.} Z=zeros(size(Big)) Z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 size(Big) ans = 3 6 Big Big = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 Big+Z ans = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 Big*Z' ans = 0 0 0 0 0 0 0 0 0 I=eye(6) I = 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 Big Big = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 Big*I ans = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 I=eye(3) I = 1 0 0 0 1 0 0 0 1 I*Big ans = 1 2 3 1 0 7 0 5 6 2 5 8 7 8 9 3 6 9 % a matrix A is symmetric if A' = A S = [3 4 5; 4 6 7; 5 7 8] S = 3 4 5 4 6 7 5 7 8 S' ans = 3 4 5 4 6 7 5 7 8 % Eigenvalues and eigenvectors % If for a squre matrix A. % A v = lambda v with v not zero % then v is an eigenvector of A and % lambda is the corresponding eigenvalue. C=1 C = 1 S = [ 0 C 0; C 0 0; 0 0 0] S = 0 1 0 1 0 0 0 0 0 lambda=eig(S) lambda = -1 0 1 lookfor eigenvalue eigshow - Graphical demonstration of eigenvalues and singular values. expmdemo3 - Matrix exponential via eigenvalues and eigenvectors. mat4bvp - Find the fourth eigenvalue of the Mathieu's equation. rosser - Classic symmetric eigenvalue test problem. wilkinson - Wilkinson's eigenvalue test matrix. balance - Diagonal scaling to improve eigenvalue accuracy. condeig - Condition number with respect to eigenvalues. eig - Eigenvalues and eigenvectors. ordeig - Eigenvalues of quasitriangular matrices. ordqz - Reorder eigenvalues in QZ factorization. ordschur - Reorder eigenvalues in Schur factorization. polyeig - Polynomial eigenvalue problem. qz - QZ factorization for generalized eigenvalues. eigs - Find a few eigenvalues and eigenvectors of a matrix dsort - Sort complex discrete eigenvalues in descending order. esort - Sort complex continuous eigenvalues in descending order. lyap2 - Lyapunov equation solution using eigenvalue decomposition. lambda lambda = -1 0 1 lambda1=lambda(1) lambda1 = -1 lambda2=lambda(2) lambda2 = 0 lambda3=lambda(3) lambda3 = 1 %lambda=eig(S) [E Lambda]=eig(A) E = -0.2401 -0.3201 0.3022 -0.4801 -0.6402 -0.7932 -0.8437 0.6983 0.5288 Lambda = 15.5440 0 0 0 -1.5440 0 0 0 1.0000 [E Lambda]=eig(S) E = -0.7071 0 0.7071 0.7071 0 0.7071 0 1.0000 0 Lambda = -1 0 0 0 0 0 0 0 1 e1=E(:,1) e1 = -0.7071 0.7071 0 e2=E(:,2) e2 = 0 0 1 e3=E(:,3) e3 = 0.7071 0.7071 0 S*e1 ans = 0.7071 -0.7071 0 lambda1*e1 ans = 0.7071 -0.7071 0 lambda1*e1 - S*e1 ans = 0 0 0 lambda2*e2 - S*e2 ans = 0 0 0 lambda3*e3 - S*e3 ans = 0 0 0 S S = 0 1 0 1 0 0 0 0 0 % the eigenvalues of a (real) symmetric matrix are real % the eigenvectors of real symmetric matrices can always be taken to be % of length 1 and mutually orthogonal v1 {Undefined function or variable 'v1'.} e1 e1 = -0.7071 0.7071 0 e2 e2 = 0 0 1 e1'*e2 ans = 0 e1*e3 {Error using * Inner matrix dimensions must agree.} e1'*e3 ans = 0 e2'*e3 ans = 0 e1'*e2 ans = 0 e1'*e1 ans = 1.0000 e2'*e2 ans = 1 e3'*e3 ans = 1.0000 E E = -0.7071 0 0.7071 0.7071 0 0.7071 0 1.0000 0 E'*E ans = 1.0000 0 -0.0000 0 1.0000 0 -0.0000 0 1.0000 % For complex matrices, the same observation only