Contents
- Vektornorm
- Beispiel Loesbarkeit eines linearen Gleichungssystems
- LU-Zerlegung
- Inverse, Pseudoinverse und Backslash-Operator
- Least Square Fit 10.2.5
- Diagonale und Blockdiagonale
- Beispiel: Diskretisierung der Poissongleichung
- QZ-Faktorisierung
- Schur-Form
- Matrix-Funktionen: Matrixwurzel
- Matrixfunktionen: funm
% Beispiele zu Kapitel 10 % Matlab Kompakt 2. Auflage % W. Schweizer % 08/2006 %
Vektornorm
MATLAB unterstuetzt verschiedene Vektornormen (vgl. 10.1.2)
x=[1 -2 3] % x = % 1 -2 3 norm(x) % ans = % 3.7417 norm(x,1.34) % ans = % 4.6716 norm(x,inf) % ans = % 3 norm(x,2) % ans = % 3.7417 norm(x,-inf) % ans = % 3
x =
1 -2 3
ans =
3.7417
ans =
4.6716
ans =
3
ans =
3.7417
ans =
1
Beispiel Loesbarkeit eines linearen Gleichungssystems
echo on A=magic(4) % 1. Beispiel A*x = b rank(A) b=rand(4,1) rref([A b]) % nicht exakt l"osbar B=randn(4) % 2. Beispiel B*x = b rref([B b]) rank(B) xA=A\b % Unser 1. Beispiel v.o. resA=sum(abs(b.^2-(A*xA).^2)) % Das Residuum xB=B\b % Unser 2. Beispiel v.o. resB=sum(abs(b.^2-(B*xB).^2)) % Numerisch exakt echo off
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
ans =
3
b =
0.1791
0.1038
0.3585
0.3077
ans =
1.0000 0 0 1.0000 0
0 1.0000 0 3.0000 0
0 0 1.0000 -3.0000 0
0 0 0 0 1.0000
B =
0.4282 0.0403 -0.3775 0.1184
0.8956 0.6771 -0.2959 0.3148
0.7310 0.5689 -1.4751 1.4435
0.5779 -0.2556 -0.2340 -0.3510
ans =
1.0000 0 0 0 1.1691
0 1.0000 0 0 -1.5631
0 0 1.0000 0 1.1337
0 0 0 1.0000 1.4310
ans =
4
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.306145e-17.
xA =
1.0e+14 *
-0.8377
-2.5130
2.5130
0.8377
resA =
0.1102
xB =
1.1691
-1.5631
1.1337
1.4310
resB =
2.6541e-16
LU-Zerlegung
echo on A=magic(4) [L,U] = lu(A) L*U echo off
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
L =
1.0000 0 0 0
0.3125 0.7685 1.0000 0
0.5625 0.4352 1.0000 1.0000
0.2500 1.0000 0 0
U =
16.0000 2.0000 3.0000 13.0000
0 13.5000 14.2500 -2.2500
0 0 -1.8889 5.6667
0 0 0 0.0000
ans =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Inverse, Pseudoinverse und Backslash-Operator
Vergleich der Loesungen fuer A * x = b
% a) fuer ein ueberbestimmtes System A=[1 1 -1;2 1 1;1 0 3;1 2 3]; b=rand(4,1) % b = % 0.6038 % 0.2722 % 0.1988 % 0.0153 % Berechnung mit pinv xp=pinv(A)*b % xp = % 0.2716 % 0.0061 % -0.0814 norm(xp) % ans = % 0.2836 norm(A*xp-b) % ans = % 0.3580 % Berechnung mit \ xb=A\b % xb = % 0.2716 % 0.0061 % -0.0814 norm(xb) % ans = % 0.2836 norm(A*xb-b) % ans = % 0.3580 % b) fuer ein unterbestimmtes System A=[1 1 -1;2 1 1;1 0 3;1 2 3]'; b=rand(3,1) % b = % 0.7468 % 0.4451 % 0.9318 % Berechnung mit pinv xp=pinv(A)*b % xp = % 0.0590 % 0.2145 % 0.1730 % 0.0858 norm(xp) % ans = % 0.2946 norm(A*xp-b) % ans = % 2.4825e-16 % Berechnung mit \ xb=A\b % xb = % 0.3271 % 0 % 0.3607 % 0.0590 norm(xb) % ans = % 0.4905 norm(A*xb-b)
b =
0.7482
0.8175
0.3369
0.3964
xp =
0.4568
0.0840
-0.0717
ans =
0.4700
ans =
0.1985
xb =
0.4568
0.0840
-0.0717
ans =
0.4700
ans =
0.1985
b =
0.7325
0.8286
0.2180
xp =
0.2483
0.1973
-0.1018
0.1915
ans =
0.3842
ans =
3.9350e-16
xb =
0.4949
0
0.0708
0.1669
ans =
0.5270
ans =
2.6185e-16
Least Square Fit 10.2.5
Vergleich von lsqnonneg, pinv und \
C = [
0.0372 0.2869
0.6861 0.7071
0.6233 0.6245
0.6344 0.6170];
d = [
0.8587
0.1781
0.0747
0.8405];
x = [C\d pinv(C)*d lsqnonneg(C,d)]
% x =
% -2.5627 -2.5627 0
% 3.1108 3.1108 0.6929
[norm(C*x(:,1)-d) norm(C*x(:,3)-d)]
% ans =
% 0.6674 0.9118
x =
-2.5627 -2.5627 0
3.1108 3.1108 0.6929
ans =
0.6674 0.9118
Diagonale und Blockdiagonale
A = [1 100 10000; .01 1 100; .0001 .01 1] [T,B] = balance(A) % A schlecht konditioniert % T = % 1.0e+03 * % 2.0480 0 0 % 0 0.0320 0 % 0 0 0.0003 % % B = % 1.0000 1.5625 1.2207 % 0.6400 1.0000 0.7812 % 0.8192 1.2800 1.0000 eig(B) % identische Eigenwerte % ans = % 0 % 3 % 0 eig(A) % identische Eigenwerte % ans = % 0 % 3 % 0 T\A*T % == B % ans = % 1.0000 1.5625 1.2207 % 0.6400 1.0000 0.7812 % 0.8192 1.2800 1.0000 [S,P,B] = balance(A) % S = P = % 1.0e+03 * 1 % 2.0480 2 % 0.0320 3 % 0.0003 % B = % 1.0000 1.5625 1.2207 % 0.6400 1.0000 0.7812 % 0.8192 1.2800 1.0000 T(:,P) = diag(S) % vgl. T oben % T = % 1.0e+03 * % 2.0480 0 0 % 0 0.0320 0 % 0 0 0.0003 B(P,P) = diag(1./S)*A*diag(S) % vgl. B oben % B = % 1.0000 1.5625 1.2207 % 0.6400 1.0000 0.7812 % 0.8192 1.2800 1.0000 % eig fuehrt automatisch balance aus. Um dies zu unterdruecken, % dient das Flag nobalance. eig(A,'nobalance') % ans = % 0.0000 % 3.0000 % -0.0000 eig(A) % ans = % 0 % 3 % 0
A =
1.0e+04 *
0.0001 0.0100 1.0000
0.0000 0.0001 0.0100
0.0000 0.0000 0.0001
T =
1.0e+03 *
2.0480 0 0
0 0.0320 0
0 0 0.0003
B =
1.0000 1.5625 1.2207
0.6400 1.0000 0.7812
0.8192 1.2800 1.0000
ans =
0
3.0000
-0.0000
ans =
0
3.0000
-0.0000
ans =
1.0000 1.5625 1.2207
0.6400 1.0000 0.7812
0.8192 1.2800 1.0000
S =
1.0e+03 *
2.0480
0.0320
0.0003
P =
1
2
3
B =
1.0000 1.5625 1.2207
0.6400 1.0000 0.7812
0.8192 1.2800 1.0000
T =
1.0e+03 *
2.0480 0 0
0 0.0320 0
0 0 0.0003
B =
1.0000 1.5625 1.2207
0.6400 1.0000 0.7812
0.8192 1.2800 1.0000
ans =
0.0000
3.0000
-0.0000
ans =
0
3.0000
-0.0000
Beispiel: Diskretisierung der Poissongleichung
clear A=gallery('poisson',100); % whos % Name Size Bytes Class % % A 10000x10000 755204 double array (sparse) % % Grand total is 59600 elements using 755204 bytes % % Damit haben wir eine duenn besetzte $10000\times 10000$-Matrix erzeugt. Alle % 10000 Eigenwerte machen sicherlich keinen Sinn. Die groessten drei % erhalten wir mit: % eig1=eigs(A,3) % Iteration 1: a few Ritz values of the 20-by-20 % 0 matrix: % 0 % 0 % Iteration 2: a few Ritz values of the 20-by-20 % 7.6360 matrix: % 7.8431 % 7.9679 % % Iteration 119: a few Ritz values of the 20-by-20 % 7.9952 matrix: % 7.9952 % 7.9981 % % % eig1 = % % 7.9981 % 7.9952 % 7.9952 % ..... 119 Iterationen das gesuchte Ergebnis erhalten. % Mit eigs(A,k, sigma) koennen wir eine andere Auswahl treffen: eig2=eigs(A,3,1.5) % Iteration 1: a few Ritz values of the 20-by-20 % 0 matrix: % 0 % 0 % % Iteration 2: a few Ritz values of the 20-by-20 % 343.0137 matrix: % 668.7737 % 668.7737 % % Iteration 3: a few Ritz values of the 20-by-20 % 343.0137 matrix: % 668.7737 % 668.7737 % % % eig2 = % % 1.5029 % 1.5015 % 1.5015 % und erhalten bereits nach drei Iterationen ein Ergebnis.
Iteration 1: a few Ritz values of the 20-by-20 matrix:
0
0
0
Iteration 2: a few Ritz values of the 20-by-20 matrix:
7.6379
7.8415
7.9678
Iteration 3: a few Ritz values of the 20-by-20 matrix:
7.8859
7.9505
7.9879
Iteration 4: a few Ritz values of the 20-by-20 matrix:
7.9432
7.9745
7.9918
Iteration 5: a few Ritz values of the 20-by-20 matrix:
7.9663
7.9862
7.9946
Iteration 6: a few Ritz values of the 20-by-20 matrix:
7.9747
7.9895
7.9968
Iteration 7: a few Ritz values of the 20-by-20 matrix:
7.9808
7.9904
7.9974
Iteration 8: a few Ritz values of the 20-by-20 matrix:
7.9867
7.9916
7.9977
Iteration 9: a few Ritz values of the 20-by-20 matrix:
7.9890
7.9934
7.9979
Iteration 10: a few Ritz values of the 20-by-20 matrix:
7.9896
7.9944
7.9980
Iteration 11: a few Ritz values of the 20-by-20 matrix:
7.9899
7.9949
7.9980
Iteration 12: a few Ritz values of the 20-by-20 matrix:
7.9900
7.9951
7.9981
Iteration 13: a few Ritz values of the 20-by-20 matrix:
7.9901
7.9951
7.9981
Iteration 14: a few Ritz values of the 20-by-20 matrix:
7.9902
7.9951
7.9981
Iteration 15: a few Ritz values of the 20-by-20 matrix:
7.9902
7.9952
7.9981
Iteration 16: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 17: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 18: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 19: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 20: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 21: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 22: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 23: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 24: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 25: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 26: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 27: a few Ritz values of the 20-by-20 matrix:
7.9903
7.9952
7.9981
Iteration 28: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 29: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 30: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 31: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 32: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 33: a few Ritz values of the 20-by-20 matrix:
7.9904
7.9952
7.9981
Iteration 34: a few Ritz values of the 20-by-20 matrix:
7.9905
7.9952
7.9981
Iteration 35: a few Ritz values of the 20-by-20 matrix:
7.9905
7.9952
7.9981
Iteration 36: a few Ritz values of the 20-by-20 matrix:
7.9906
7.9952
7.9981
Iteration 37: a few Ritz values of the 20-by-20 matrix:
7.9906
7.9952
7.9981
Iteration 38: a few Ritz values of the 20-by-20 matrix:
7.9907
7.9952
7.9981
Iteration 39: a few Ritz values of the 20-by-20 matrix:
7.9908
7.9952
7.9981
Iteration 40: a few Ritz values of the 20-by-20 matrix:
7.9909
7.9952
7.9981
Iteration 41: a few Ritz values of the 20-by-20 matrix:
7.9911
7.9952
7.9981
Iteration 42: a few Ritz values of the 20-by-20 matrix:
7.9912
7.9952
7.9981
Iteration 43: a few Ritz values of the 20-by-20 matrix:
7.9913
7.9952
7.9981
Iteration 44: a few Ritz values of the 20-by-20 matrix:
7.9915
7.9952
7.9981
Iteration 45: a few Ritz values of the 20-by-20 matrix:
7.9916
7.9952
7.9981
Iteration 46: a few Ritz values of the 20-by-20 matrix:
7.9917
7.9952
7.9981
Iteration 47: a few Ritz values of the 20-by-20 matrix:
7.9918
7.9952
7.9981
Iteration 48: a few Ritz values of the 20-by-20 matrix:
7.9919
7.9952
7.9981
Iteration 49: a few Ritz values of the 20-by-20 matrix:
7.9920
7.9952
7.9981
Iteration 50: a few Ritz values of the 20-by-20 matrix:
7.9920
7.9952
7.9981
Iteration 51: a few Ritz values of the 20-by-20 matrix:
7.9921
7.9952
7.9981
Iteration 52: a few Ritz values of the 20-by-20 matrix:
7.9921
7.9952
7.9981
Iteration 53: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 54: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 55: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 56: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 57: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 58: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 59: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 60: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 61: a few Ritz values of the 20-by-20 matrix:
7.9922
7.9952
7.9981
Iteration 62: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 63: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 64: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 65: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 66: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 67: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 68: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 69: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 70: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 71: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 72: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 73: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 74: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 75: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 76: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 77: a few Ritz values of the 20-by-20 matrix:
7.9923
7.9952
7.9981
Iteration 78: a few Ritz values of the 20-by-20 matrix:
7.9948
7.9952
7.9981
Iteration 79: a few Ritz values of the 20-by-20 matrix:
7.9951
7.9952
7.9981
Iteration 80: a few Ritz values of the 20-by-20 matrix:
7.9951
7.9952
7.9981
Iteration 81: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 82: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 83: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 84: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 85: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 86: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 87: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 88: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 89: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 90: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 91: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 92: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 93: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 94: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 95: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 96: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 97: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 98: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 99: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 100: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 101: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 102: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 103: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 104: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 105: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 106: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 107: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 108: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 109: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 110: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 111: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 112: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 113: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 114: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
Iteration 115: a few Ritz values of the 20-by-20 matrix:
7.9952
7.9952
7.9981
eig1 =
7.9981
7.9952
7.9952
Iteration 1: a few Ritz values of the 20-by-20 matrix:
0
0
0
Iteration 2: a few Ritz values of the 20-by-20 matrix:
343.0137
668.7737
668.7737
Iteration 3: a few Ritz values of the 20-by-20 matrix:
343.0137
668.7737
668.7737
eig2 =
1.5029
1.5015
1.5015
QZ-Faktorisierung
% verallgemeinertes Eigenwertproblem: % linke Seite A =[ 1090 900 725 690 820 850 1075 815 720 765 700 840 1145 840 700 765 720 815 1075 850 820 690 725 900 1090] % Rechte Seite B =[ 0.1682 0.6756 0 0 0 0.6756 0.9087 0.6992 0 0 0 0.6992 0.8837 0.7275 0 0 0 0.7275 0.7065 0.4784 0 0 0 0.4784 0.3072] [AA,BB,Q,Z,v,w] = qz(A,B) % QZ-Zerlegung % AA = % 1.0e+03 * % 2.6674 0.6045 -1.2487 0.0608 2.9316 % 0 -0.1731 0.0126 0.0032 0.0790 % 0 0 -0.1890 -0.0478 0.1105 % 0 0 0 0.4689 0.0053 % 0 0 0 0 0.6282 % % BB = % 0.7496 0.1397 -0.0713 -0.0061 1.4898 % 0 0.1219 0.0121 -0.1942 0.1556 % 0 0 0.4691 -0.0271 -0.1541 % 0 0 0 1.1516 -0.0770 % 0 0 0 0 1.0843 % % Q = .... % fuer das Beispiel nicht wichtig % % Z = .... % fuer das Beispiel nicht wichtig % % v = .... % fuer das Beispiel nicht wichtig % % w = .... % fuer das Beispiel nicht wichtig % % logischer Vektor [0 1 0 1 1] zur Umordnung [AAS,BBS,QS,ZS]=ordqz(AA,BB,Q,Z,[0 1 0 1 1]) % AAS = % 1.0e+03 * % -0.1719 -0.0117 -0.0104 0.5972 -0.3832 % 0 0.4677 -0.0365 -0.2367 0.2386 % 0 0 0.6496 2.4764 -1.6857 % 0 0 0 2.3815 -1.5369 % 0 0 0 0 -0.2067 % % BBS = % 0.1210 0.1824 0.0164 0.1544 -0.0482 % 0 1.1486 -0.1336 -0.0464 0.1556 % 0 0 1.1213 1.2764 -0.7418 % 0 0 0 0.6692 -0.2224 % 0 0 0 0 0.5131 % % unwesentliche Ergebnisse ausgespart % ..... AA./BB % liefert die Eigenwerte % Warning: Divide by zero. % (Type "warning off MATLAB:divideByZero" % to suppress this warning.) % % ans = % 1.0e+04 * % 0.3558 0.4328 1.7508 -1.0006 0.1968 % NaN -0.1421 0.1046 -0.0016 0.0507 % NaN NaN -0.0403 0.1766 -0.0717 % NaN NaN NaN 0.0407 -0.0069 % NaN NaN NaN NaN 0.0579 % AAS./BBS % Warning: Divide by zero. % (Type "warning off MATLAB:divideByZero" % to suppress this warning.) % % ans = % 1.0e+03 * % -1.4206 -0.0642 -0.6328 3.8672 7.9560 % NaN 0.4071 0.2730 5.1057 1.5338 % NaN NaN 0.5793 1.9401 2.2724 % NaN NaN NaN 3.5585 6.9105 % NaN NaN NaN NaN -0.4028 % % logischer Vektor [0 1 0 1 1] fuehrt zu: % (22) -> (11) | (44) -> (22) | (55) -> (33)
A =
1090 900 725 690 820
850 1075 815 720 765
700 840 1145 840 700
765 720 815 1075 850
820 690 725 900 1090
B =
0.1682 0.6756 0 0 0
0.6756 0.9087 0.6992 0 0
0 0.6992 0.8837 0.7275 0
0 0 0.7275 0.7065 0.4784
0 0 0 0.4784 0.3072
AA =
1.0e+03 *
2.6674 0.6045 -1.2487 0.0608 2.9316
0 -0.1731 0.0126 0.0032 0.0789
0 0 -0.1890 -0.0478 0.1105
0 0 0 0.4689 0.0053
0 0 0 0 0.6282
BB =
0.7496 0.1397 -0.0714 -0.0061 1.4898
0 0.1219 0.0121 -0.1942 0.1556
0 0 0.4691 -0.0271 -0.1541
0 0 0 1.1516 -0.0770
0 0 0 0 1.0843
Q =
-0.4637 -0.4513 -0.3545 -0.4492 -0.5039
0.4963 -0.3536 -0.2704 0.5805 -0.4675
-0.4993 0.5589 -0.4665 0.4547 -0.1183
0.4825 0.5809 -0.1790 -0.4756 -0.4142
0.2380 -0.1469 -0.7427 -0.1679 0.5848
Z =
-0.2236 -0.6182 0.6315 0.4076 -0.0546
-0.4588 0.1476 -0.4460 0.6024 -0.4538
0.3285 0.2538 0.3844 -0.1395 -0.8127
-0.3233 -0.5634 -0.3088 -0.6003 -0.3497
-0.7260 0.4629 0.3989 -0.3020 0.0916
v =
-0.3079 -0.9209 0.7484 0.2021 0.4659
-0.6320 0.3978 -1.0000 1.0000 -0.1561
0.4525 0.2958 0.9062 -0.1769 -1.0000
-0.4454 -0.7978 -0.8502 -0.9364 -0.4864
-1.0000 1.0000 0.2870 -0.0696 0.8264
w =
-0.2755 0.9403 -0.7965 0.7147 0.3204
-0.6279 -0.4979 1.0000 1.0000 -0.1979
0.4597 -0.2763 -0.7395 -0.0545 -1.0000
-0.4473 0.8693 0.7180 -0.7260 -0.2261
-1.0000 -1.0000 -0.2826 -0.8677 0.7874
AAS =
1.0e+03 *
-0.1719 -0.0117 -0.0104 0.5974 -0.3833
0 0.4677 -0.0365 -0.2366 0.2386
0 0 0.6496 2.4763 -1.6857
0 0 0 2.3815 -1.5369
0 0 0 0 -0.2067
BBS =
0.1210 0.1824 0.0165 0.1545 -0.0482
0 1.1486 -0.1336 -0.0463 0.1555
0 0 1.1213 1.2764 -0.7419
0 0 0 0.6692 -0.2224
0 0 0 0 0.5131
QS =
-0.5696 0.2695 0.2044 -0.6500 0.3724
0.5413 0.5841 -0.1165 -0.4737 -0.3575
-0.0510 -0.3932 -0.8426 -0.3627 0.0358
-0.3892 -0.2675 0.1942 -0.1893 -0.8387
-0.4780 0.6001 -0.4438 0.4309 -0.1696
ZS =
0.5573 0.3718 0.3536 -0.1573 0.6335
-0.2408 0.6740 -0.2936 -0.6101 -0.1713
-0.1790 -0.2054 -0.6959 -0.0080 0.6644
0.4828 -0.5311 -0.1453 -0.6528 -0.1940
-0.6052 -0.2887 0.5324 -0.4205 0.3003
Warning: Divide by zero.
ans =
1.0e+04 *
0.3558 0.4328 1.7501 -1.0014 0.1968
NaN -0.1421 0.1047 -0.0016 0.0507
NaN NaN -0.0403 0.1765 -0.0717
NaN NaN NaN 0.0407 -0.0069
NaN NaN NaN NaN 0.0579
Warning: Divide by zero.
ans =
1.0e+03 *
-1.4208 -0.0642 -0.6278 3.8664 7.9515
NaN 0.4071 0.2730 5.1060 1.5339
NaN NaN 0.5793 1.9401 2.2723
NaN NaN NaN 3.5585 6.9100
NaN NaN NaN NaN -0.4029
Schur-Form
A=magic(4); % Testmatrix [U,O]=schur(A) % U = % -0.5000 -0.8236 -0.1472 -0.2236 % -0.5000 0.4236 0.3472 -0.6708 % -0.5000 0.0236 0.5472 0.6708 % -0.5000 0.3764 -0.7472 0.2236 % % O = % 34.0000 0.0000 0.0000 0.0000 % 0 8.9443 13.4164 -0.0000 % 0 0 -8.9443 0.0000 % 0 0 0 0.0000 % Umordnung: 0 an oberster Stelle [US,OS]=ordschur(U,O,[1 3 2 4]) % US = % -0.2236 0.8236 -0.1472 -0.5000 % -0.6708 -0.4236 0.3472 -0.5000 % 0.6708 -0.0236 0.5472 -0.5000 % 0.2236 -0.3764 -0.7472 -0.5000 % % OS = % 0.0000 -0.0000 -0.0000 -0.0000 % 0 8.9443 -13.4164 0.0000 % 0 0 -8.9443 -0.0000 % 0 0 0 34.0000
U =
-0.5000 -0.8236 -0.1472 -0.2236
-0.5000 0.4236 0.3472 -0.6708
-0.5000 0.0236 0.5472 0.6708
-0.5000 0.3764 -0.7472 0.2236
O =
34.0000 0.0000 0.0000 0.0000
0 8.9443 13.4164 -0.0000
0 0 -8.9443 0.0000
0 0 0 0.0000
US =
-0.2236 0.8236 -0.1472 -0.5000
-0.6708 -0.4236 0.3472 -0.5000
0.6708 -0.0236 0.5472 -0.5000
0.2236 -0.3764 -0.7472 -0.5000
OS =
0.0000 0.0000 -0.0000 -0.0000
0 8.9443 -13.4164 0.0000
0 0 -8.9443 -0.0000
0 0 0 34.0000
Matrix-Funktionen: Matrixwurzel
A=magic(4) % A = % 16 2 3 13 % 5 11 10 8 % 9 7 6 12 % 4 14 15 1 [y,alpha,kon] = sqrtm(A) % y = .... % alpha = % 1.6017 % kon = % 7.6311e+07 % As =[ 16 0 0 0 0 11 0 0 0 0 6 0 0 0 0 1] [y,alpha,kon] = sqrtm(As) % y = % 4.0000 0 0 0 % 0 3.3166 0 0 % 0 0 2.4495 0 % 0 0 0 1.0000 % alpha = % 1.6710 % kon = % 1.7445
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
y =
3.7584 - 0.2071i -0.2271 + 0.4886i 0.3887 + 0.7700i 1.9110 - 1.0514i
0.2745 - 0.0130i 2.3243 + 0.0306i 2.0076 + 0.0483i 1.2246 - 0.0659i
1.3918 - 0.2331i 1.5060 + 0.5498i 1.4884 + 0.8666i 1.4447 - 1.1833i
0.4063 + 0.4533i 2.2277 - 1.0691i 1.9463 - 1.6848i 1.2506 + 2.3006i
alpha =
1.6017
kon =
3.0095e+08
As =
16 0 0 0
0 11 0 0
0 0 6 0
0 0 0 1
y =
4.0000 0 0 0
0 3.3166 0 0
0 0 2.4495 0
0 0 0 1.0000
alpha =
1.6710
kon =
1.7445
Matrixfunktionen: funm
A=pi*rand(3) % A = % 0.5997 0.5366 1.0683 % 2.6511 3.1237 0.9871 % 0.5463 1.3816 1.1469 ys = sin(A) % elementweise % ys = % 0.5644 0.5112 0.8764 % 0.4711 0.0179 0.8345 % 0.5195 0.9822 0.9115 [y, err] = funm(A, @sin) % Matrixergebnis % y = % -0.1471 -0.4683 0.5163 % -0.1497 -0.3751 -1.0720 % -0.8229 -0.3241 0.2231 % err = % 0 %%%% 2. Beispiel ABER A=pi*rand(2,3) % A = % 2.9849 1.9065 2.8001 % 0.7261 1.5268 2.3942 zs = sin(A) % Elementweise Berechnung % zs = % 0.1560 0.9442 0.3349 % 0.6640 0.9990 0.6797 [y, err]=funm(A,@sin) % Matrixoperation % ??? Error using ==> schur % Matrix must be square. % % Error in ==> funm at 149 % [U,T] = schur(A,'complex'); % Bei Matrixoperation ist die Dimension der Matrix wichtig
Error using ==> funm First input must be a square matrix.