MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Tue Mar 09 14:34:00 2004 IM0jn"@ kom Hipndp ny sG% ******************* MATEMATICK SEMIN . 4 ************************+V% 4.1. ZKLADN MATICOV OPERTORY A FUNKCEh4% 4.2. OPERACE PO SLOKCHx#F% 4.3. PRAV A LEV MATICOV DLENh4% 4.4. MATICOV UMOCOVN0%P% Copyright (C) 1996-2003 by V. Vesel (Masaryk University Brno, Czech Republic)0%.\% Dvka je kompletn upravena pro menu-systm.0 @echo on@more onPformat compact8clcG%======================================================================+V% 4.1. ZKLADN MATICOV OPERTORY A FUNKCEG%----------------------------------------------------------------------p:%% stn (+), odetn (-)x!B%% X=A+B <=> X(r,s)=A(r,s)+B(r,s)&L%% X=a+B <=> X(r,s)=a+B(r,s), a skalr&L%% X=A+b <=> X(r,s)=A(r,s)+b, b skalr0%%`.%% Podobn pro odtn/^%% sum(v) = v(1)+v(2)+...+v(n), kde v je vektorH%% sum(A) = [sum(A(:,1)),...,sum(A(:,n))] ... dkov vektor sloupcovch4h%% soutF a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;@ A+B@ A-B@ pause;G%----------------------------------------------------------------------@ a+B@ A+b@ pause;G%----------------------------------------------------------------------@ sum(v)@ sum(A)@ pause;0.\%% transpozice (.') a hermitovsk opertor (')h4%% X=A.' <=> X(r,s)=A(s,r)K%% X=A.' <=> X(r,s)=conj(A(s,r)), kde conj() zna komplexn sdruen slo%J A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2]@ Bt=B.'H  C=A+i*B8 C'@ C.'@ pause;0?~%% maticov nsoben (*), Kroneckerv (tensorov) souin (kron)2d%% skalrn souin (dot), vektorov souin (cross)0%%(P%% X=A*B <=> X(r,s)=suma{k}A(r,k)*B(k,s)&L%% X=a*B <=> X(r,s)=a*B(r,s), a skalr&L%% X=A*b <=> X(r,s)=A(r,s)*b, b skalrp>%% X=kron(A,B) <=> X=[A(r,s)*B]0%%;v%% dot(u,v) = suma{k}conj(u(k))*v(k), kde u, v jsou vektory9r%% dot(A,B) = [dot(A(:,1),B(:,1)),...,dot(A(:,n),B(:,n))]N%% cross(u,v)=w=[u(2)*v(3)-u(3)*v(2),u(3)*v(1)-u(1)*v(3),u(1)*v(2)-u(2)*v(1)],E%% kde u, v jsou 3-prvkov vektory (w je kolm na u i v)?~%% cross(A,B) = [cross(A(:,1),B(:,1)),...,cross(A(:,n),B(:,n))]1b%% prod(v) = v(1)*v(2)*...*v(n), kde v je vektorK%% prod(A) = [prod(A(:,1)),...,prod(A(:,n)) ... dkov vektor sloupcovch8p%% souinF a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;@ Bt=B.'@ M=A*Bt@ a*B@ A*bH  kron(A,B)H keyboard;0H  dot(u,v)P % je tot jako:P u*v.', v*u.'H  dot(A,B)@ pause;G%----------------------------------------------------------------------x"D uu=u(1:3), vv=v(1:3), uv=[uu;vv]P w=cross(uu,vv)P % je tot jako:7n [det(uv(:,[2,3])),-det(uv(:,[1,3])),det(uv(:,[1,2]))]X(% kontrola kolmosti:`, dot(w,uu), dot(w,vv)P cross(A.',B.')@ pause;0A prod(v) % =5! ... obecn prod(1:n)=n! (n faktoril), piem+V prod(1:0) % prod(1:0)=prod([])=1H  prod(A)H keyboard;0(P%% Hodnost, inverze a determinant maticep>%% rank(A) ... hodnost matice A)R%% inv(A) ... inverze tvercov matice Ax#F%% det(A) ... determinant matice A=z%% trace(A)... stopa matice (souet prvk v hlavn diagonle)F a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;H  Bt=B.';H  M=A*Bt;8 MH  rank(M)@ inv(M)H  inv(M)*M@ det(M)H  trace(M)H keyboard;0G%======================================================================h4% 4.2. OPERACE PO SLOKCHG%----------------------------------------------------------------------E%% nsoben (.*), prav dlen (./), lev dlen(.\), umocovn (.^)x"D%% X=A.*B <=> X(r,s)=A(r,s)*B(r,s)'N%% X=a.*B <=> X(r,s)=a*B(r,s), a skalr'N%% X=A.*b <=> X(r,s)=A(r,s)*b, b skalr'N%% X=A./B=B.\A <=> X(r,s)=A(r,s):B(r,s),X%% X=a./B=B.\a <=> X(r,s)=a:B(r,s), a skalr,X%% X=A./b=b.\A <=> X(r,s)=A(r,s):b, b skalrx"D%% X=A.^B <=> X(r,s)=A(r,s)^B(r,s)'N%% X=a.^B <=> X(r,s)=a^B(r,s), a skalr'N%% X=A.^b <=> X(r,s)=A(r,s)^b, b skalr5j a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2];@ Bt=B.'@ M=A*Bt@ A.*B@ a.*B@ A.*b@ pause;G%----------------------------------------------------------------------P D=A./B, B.\A@ pause;G%----------------------------------------------------------------------H  a./B, B.\a@ pause;G%----------------------------------------------------------------------H  A./b, b.\A@ pause;G%----------------------------------------------------------------------@ A.^B@ 2.^B@ A.^2H keyboard;0G%======================================================================+V% 4.3. PRAV (/) A LEV (\) MATICOV DLENG%----------------------------------------------------------------------0`%% X=A\B <=> X je een maticov rovnice A*X=B8p%% POZOR! 2. \A=2\A nen tot jako 2.\A=2 .\A0`%% X=B/A <=> X je een maticov rovnice X*A=B8p%% POZOR! 2. /A=2/A nen tot jako 2./A=2 ./A0`%% B/A=(A.'\B.').' , nebo X*A=B <=> A.'*X.'=B.'0%%X(%% ALGORITMUS PRO \:5j%% (1) A tvercov => X=inv(A)*B (Gaussova eliminace)B%% A (skoro) singulrn=> chybov varovn (een bez zruky)H%% (2) A netvercov => X je (njak) een ve smyslu metody nejmenchF%% tverc (MN), tj. minimalizujc euklidovskou>|%% normu ||A*X(:,s)-B(:,s)|| pro kad s.h8%% een vdy existuje.Da=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;H  Bt=B.';H  M=A*Bt;@ X=A\B@ A*X-B@ pause;G%----------------------------------------------------------------------@ v=v.'P 60./v, 60 ./vP % je rzn odP 60. /v, 60/v@ pause;G%----------------------------------------------------------------------P% A netvercovH  X=B/A %@ X*A-BP  (A.'\B.').'@ pause;G%----------------------------------------------------------------------%J% doplnme A na singulrn tvercovouP A=[A;sum(A)]`. B=[B.',A(:,1)+A(:,2)]@ A\B@ pause;G%----------------------------------------------------------------------A% algoritmus (1) selhal, doplnme proto dek nul na ekvivalentn=z% systm s netvercovou matic soustavy, abychom mohli pout`*% MN algoritmus (2):X$ A=[A;zeros(1,3)]X$ B=[B;zeros(1,3)]@ X=A\B@ A*X-B'Nkeyboard; % Vyzkouejte prav dlen0G%======================================================================p<% 4.4. MATICOV UMOCOVN (^)G%----------------------------------------------------------------------+V%% (1) X = A^p, A tvercov n x n, p skalr0%%8p%% a) p>0 cel => A^p=A*A*...*A (p-t maticov mocnina)0%%,X%% b) p=0 => A^p=eye(n) (jednotkov matice)0%%.\%% c) p<0 cel => A^p=inv(A)*inv(A)*...*inv(A)3f%% (p-t inverzn maticov mocnina)0%%2d%% d) p necel => A^p=V*D.^p/V, kde [V,D]=eig(A) a<x%% D=diag(d(1),...,d(n)) jsou vlastn sla A;v%% V(:,s) je vlastn vektor pslun k d(s)E%% Tedy A*V=V*D a (A^p*V=V*D.^p <=> A^p=V*D.^p/V), kde.\%% D.^p=diag(d(1)^p,...,d(n)^p)F a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;H  Bt=B.';H  M=A*Bt;@ A=M@ A^2H  A^2-A*A@ pause;@ A^0@ A^(-2)`, A^(-2)-inv(A)*inv(A)H keyboard;8clc;P [V,D]=eig(A)H  A*V-V*D@ pause;@ p=2.5;@ A^pP A^p-V*D.^p/VH keyboard;0+V%% (2) X = p^A, A tvercov n x n, p skalrx"D%% p^A=V*p^D/V, kde [V,D]=eig(A) a:t%% D=diag(d(1),...,d(n)) jsou vlastn sla A9r%% V(:,s) je vlastn vektor pslun k d(s)A%% Tedy A*V=V*D a (p^A*V=V*p^D <=> p^A=V*p^D/V), kde+V%% p^D=diag(p^d(1),...,p^d(n))5j%% POZOR! nap. 2^A=2. ^A nen tot jako 2.^A=2 .^A0%%G%% Komplexn sla se ve ve uvedench operacch umocuj v komplexnmH %% oboru:D%% a^b=exp^(b*log(a)), kde pi a=r*exp(i*phi) je log(a)=log(r)+i*phi'N%% log = pirozen logaritmus v MATLABuF a=1000; b=100; A=[-2 0 2;-1 1 3], B=[-1 0 1;0 1 2], u=5:-1:1; v=1:5;H  Bt=B.';H  M=A*Bt;@ A=MP  2^A , 2. ^AP % je rzn odP  2.^A, 2 .^A@ pause;G%----------------------------------------------------------------------P [V,D]=eig(A)P  2^A-V*2^D/Vh8 2^D, 2.^D % Nen totH keyboard;P a=1+i; b=2-i;@ a^bP exp(b*log(a))H keyboard;0G%================================= KONEC ==============================0%0%0%%@more off@echo off00cpk