format compact % Priklad 1 Ar=-5+round(10*rand(3,5)) Ar = 5 0 0 -1 4 -3 4 -5 1 2 1 3 3 3 -3 Ai=-5+round(10*rand(3,5)) Ai = -1 -1 -1 -4 1 4 4 3 -3 -2 4 -4 -5 -3 -3 Br=-5+round(10*rand(3,5)) Br = -5 4 3 2 2 2 0 0 3 -1 -1 -1 -3 -5 3 Bi=-5+round(10*rand(3,5)) Bi = 0 -2 2 -3 4 2 -3 -2 2 4 -1 -3 0 -1 1 A=Ar+i*Ai A = Columns 1 through 4 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i Column 5 4.0000 + 1.0000i 2.0000 - 2.0000i -3.0000 - 3.0000i B=Br+i*Bi B = Columns 1 through 4 -5.0000 4.0000 - 2.0000i 3.0000 + 2.0000i 2.0000 - 3.0000i 2.0000 + 2.0000i 0 - 3.0000i 0 - 2.0000i 3.0000 + 2.0000i -1.0000 - 1.0000i -1.0000 - 3.0000i -3.0000 -5.0000 - 1.0000i Column 5 2.0000 + 4.0000i -1.0000 + 4.0000i 3.0000 + 1.0000i C=B.' C = -5.0000 2.0000 + 2.0000i -1.0000 - 1.0000i 4.0000 - 2.0000i 0 - 3.0000i -1.0000 - 3.0000i 3.0000 + 2.0000i 0 - 2.0000i -3.0000 2.0000 - 3.0000i 3.0000 + 2.0000i -5.0000 - 1.0000i 2.0000 + 4.0000i -1.0000 + 4.0000i 3.0000 + 1.0000i D=B' D = -5.0000 2.0000 - 2.0000i -1.0000 + 1.0000i 4.0000 + 2.0000i 0 + 3.0000i -1.0000 + 3.0000i 3.0000 - 2.0000i 0 + 2.0000i -3.0000 2.0000 + 3.0000i 3.0000 - 2.0000i -5.0000 + 1.0000i 2.0000 - 4.0000i -1.0000 - 4.0000i 3.0000 - 1.0000i % Priklad 3 Bs=B(1:3,1:3) Bs = -5.0000 4.0000 - 2.0000i 3.0000 + 2.0000i 2.0000 + 2.0000i 0 - 3.0000i 0 - 2.0000i -1.0000 - 1.0000i -1.0000 - 3.0000i -3.0000 Bs'*Bs ans = 35.0000 -22.0000 + 6.0000i -16.0000 -17.0000i -22.0000 - 6.0000i 39.0000 17.0000 + 5.0000i -16.0000 +17.0000i 17.0000 - 5.0000i 26.0000 % Matice neni unitarni, nebot Bs'*Bs neni jednotkova matice A+B ans = Columns 1 through 4 0 - 1.0000i 4.0000 - 3.0000i 3.0000 + 1.0000i 1.0000 - 7.0000i -1.0000 + 6.0000i 4.0000 + 1.0000i -5.0000 + 1.0000i 4.0000 - 1.0000i 0 + 3.0000i 2.0000 - 7.0000i 0 - 5.0000i -2.0000 - 4.0000i Column 5 6.0000 + 5.0000i 1.0000 + 2.0000i 0 - 2.0000i A.*B ans = Columns 1 through 4 -25.0000 + 5.0000i -2.0000 - 4.0000i 2.0000 - 3.0000i -14.0000 - 5.0000i -14.0000 + 2.0000i 12.0000 -12.0000i 6.0000 +10.0000i 9.0000 - 7.0000i 3.0000 - 5.0000i -15.0000 - 5.0000i -9.0000 +15.0000i -18.0000 +12.0000i Column 5 4.0000 +18.0000i 6.0000 +10.0000i -6.0000 -12.0000i A./B ans = Columns 1 through 4 -1.0000 + 0.2000i 0.1000 - 0.2000i -0.1538 - 0.2308i 0.7692 - 0.8462i 0.2500 + 1.7500i -1.3333 + 1.3333i -1.5000 - 2.5000i -0.2308 - 0.8462i -2.5000 - 1.5000i 0.9000 + 1.3000i -1.0000 + 1.6667i -0.4615 + 0.6923i Column 5 0.6000 - 0.7000i -0.5882 - 0.3529i -1.2000 - 0.6000i A*C ans = -35.0000 +11.0000i 4.0000 + 9.0000i 3.0000 +28.0000i 23.0000 -18.0000i 19.0000 + 3.0000i 30.0000 -16.0000i 21.0000 -84.0000i 2.0000 -17.0000i -45.0000 + 5.0000i % Priklad 5 E=A(:,1:3)*C(1:3,:) E = -25.0000 - 2.0000i 7.0000 + 8.0000i -9.0000 18.0000 -13.0000i 4.0000 30.0000 -26.0000i 18.0000 -51.0000i -28.0000 - 5.0000i -21.0000 + 5.0000i det(E) ans = -1.9200e+003 -1.2435e+004i det(A(:,1:3))*det(C(1:3,:)) ans = -1.9200e+003 -1.2435e+004i system_dependent('setprintcolorchoice', -1) ; ; ; ; ; ; disp(get(0, 'Echo')) off set(0, 'Echo', 'off') set(0, 'Format', 'short') set(0, 'FormatSpacing', 'compact') feature('EightyColumns', 0); system_dependent('TabCompletion', 100); % Priklad 6 help eig EIG Eigenvalues and eigenvectors. E = EIG(X) is a vector containing the eigenvalues of a square matrix X. [V,D] = EIG(X) produces a diagonal matrix D of eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that X*V = V*D. [V,D] = EIG(X,'nobalance') performs the computation with balancing disabled, which sometimes gives more accurate results for certain problems with unusual scaling. E = EIG(A,B) is a vector containing the generalized eigenvalues of square matrices A and B. [V,D] = EIG(A,B) produces a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A*V = B*V*D. EIG(A,B,'chol') is the same as EIG(A,B) for symmetric A and symmetric positive definite B. It computes the generalized eigenvalues of A and B using the Cholesky factorization of B. EIG(A,B,'qz') ignores the symmetry of A and B and uses the QZ algorithm. In general, the two algortihms return the same result, however using the QZ algorithm may be more stable for certain problems. The flag is ignored when A and B are not symmetric. See also CONDEIG, EIGS. Overloaded methods help lti/eig.m help sym/eig.m lambda=eig(E) lambda = -40.7966 -30.5895i 3.8080 - 5.0586i -5.0114 +38.6481i prod(lambda) ans = -1.9200e+003 -1.2435e+004i det(E) ans = -1.9200e+003 -1.2435e+004i sum(lambda) ans = -42.0000 + 3.0000i trace(E) ans = -42.0000 + 3.0000i % Priklad 7 [m,n]=size(A) m = 3 n = 5 [A;(1:m)*A] ans = Columns 1 through 4 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i 2.0000 +19.0000i 17.0000 - 5.0000i -1.0000 -10.0000i 10.0000 -19.0000i Column 5 4.0000 + 1.0000i 2.0000 - 2.0000i -3.0000 - 3.0000i -1.0000 -12.0000i % Priklad 8 x=B(:,1) x = -5.0000 2.0000 + 2.0000i -1.0000 - 1.0000i u=A(:,1) u = 5.0000 - 1.0000i -3.0000 + 4.0000i 1.0000 + 4.0000i xp = (dot(u,x)/dot(u,u)).*u xp = -2.2941 - 0.7647i 2.1765 - 0.9412i 0.5294 - 1.8824i dot(x-xp,u) ans = 0 dot(u,u) ans = 68 norm(u)^2 ans = 68 % Priklad 9 w=cross(x-xp,u) w = -13.0000 +11.0000i -1.0000 +16.0000i 3.0000 -28.0000i dot(w,u) ans = -1.1800e+002 +4.2000e+001i dot(w,x-xp) ans = 61.5294 -20.4706i help cross CROSS Vector cross product. C = CROSS(A,B) returns the cross product of the vectors A and B. That is, C = A x B. A and B must be 3 element vectors. C = CROSS(A,B) returns the cross product of A and B along the first dimension of length 3. C = CROSS(A,B,DIM), where A and B are N-D arrays, returns the cross product of vectors in the dimension DIM of A and B. A and B must have the same size, and both SIZE(A,DIM) and SIZE(B,DIM) must be 3. See also DOT. w=cross(u,x-xp) w = 13.0000 -11.0000i 1.0000 -16.0000i -3.0000 +28.0000i w=cross(conj(u),x-xp) w = -3.4706 - 0.1765i 8.8824 + 8.7059i -15.0000 + 6.0000i dot(w,x-xp) ans = 61.5294 +20.4706i A A = Columns 1 through 4 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i Column 5 4.0000 + 1.0000i 2.0000 - 2.0000i -3.0000 - 3.0000i kron(A,ones(3,2)) ans = Columns 1 through 4 5.0000 - 1.0000i 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i 5.0000 - 1.0000i 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i 5.0000 - 1.0000i 5.0000 - 1.0000i 0 - 1.0000i 0 - 1.0000i -3.0000 + 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i 4.0000 + 4.0000i -3.0000 + 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i 4.0000 + 4.0000i -3.0000 + 4.0000i -3.0000 + 4.0000i 4.0000 + 4.0000i 4.0000 + 4.0000i 1.0000 + 4.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 4.0000i 1.0000 + 4.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 4.0000i 1.0000 + 4.0000i 1.0000 + 4.0000i 3.0000 - 4.0000i 3.0000 - 4.0000i Columns 5 through 8 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -1.0000 - 4.0000i 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -1.0000 - 4.0000i 0 - 1.0000i 0 - 1.0000i -1.0000 - 4.0000i -1.0000 - 4.0000i -5.0000 + 3.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 - 3.0000i -5.0000 + 3.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 - 3.0000i -5.0000 + 3.0000i -5.0000 + 3.0000i 1.0000 - 3.0000i 1.0000 - 3.0000i 3.0000 - 5.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i 3.0000 - 3.0000i 3.0000 - 5.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i 3.0000 - 3.0000i 3.0000 - 5.0000i 3.0000 - 5.0000i 3.0000 - 3.0000i 3.0000 - 3.0000i Columns 9 through 10 4.0000 + 1.0000i 4.0000 + 1.0000i 4.0000 + 1.0000i 4.0000 + 1.0000i 4.0000 + 1.0000i 4.0000 + 1.0000i 2.0000 - 2.0000i 2.0000 - 2.0000i 2.0000 - 2.0000i 2.0000 - 2.0000i 2.0000 - 2.0000i 2.0000 - 2.0000i -3.0000 - 3.0000i -3.0000 - 3.0000i -3.0000 - 3.0000i -3.0000 - 3.0000i -3.0000 - 3.0000i -3.0000 - 3.0000i w=cross(x-xp,u) w = -13.0000 +11.0000i -1.0000 +16.0000i 3.0000 -28.0000i dot(conj(w),x-xp) ans = 0 w=conj(cross(x-xp,u)) w = -13.0000 -11.0000i -1.0000 -16.0000i 3.0000 +28.0000i dot(w,x-xp) ans = 0 dot(w,u) ans = 0 +1.0658e-014i diary off