MATLAB练习例子五(解方程)
返回
解线性方程
》 A = pascal(3)
A =
1 1 1
1 2 3
1 3 6
》 B = magic(3)
B =
8 1 6
3 5 7
4 9 2
》 C = fix(10*rand(3,2))
C =
9 4
2 8
6 7
》 u = [3; 1; 4]
u =
3
1
4
》 v = [2 0 -1]
v =
2 0 -1
》 s = 7
s =
7
》 x = A\u
x =
10
-12
5
》 X = A\B
X =
19 -3 -1
-17 4 13
6 0 -6
》 t = [0 .3 .8 1.1 1.6 2.3]'
t =
0
0.3000
0.8000
1.1000
1.6000
2.3000
》 y = [.82 .72 .63 .60 .55 .50]';
》 y
y =
0.8200
0.7200
0.6300
0.6000
0.5500
0.5000
》 E = [ones(size(t)) exp(-t)]
E =
1.0000 1.0000
1.0000 0.7408
1.0000 0.4493
1.0000 0.3329
1.0000 0.2019
1.0000 0.1003
》 c = E\y
c =
0.4760
0.3413
》 T = (0:0.1:2.5)';
》 Y = [ones(size(T)) exp(-T)]*c;
》 plot(T,Y,'-',t,y,'o')
》
Underdetermined Systems
》 R = fix(10*rand(2,4))
R =
0 8 1 1
3 0 2 6
》 b = fix(10*rand(2,1))
b =
2
1
》 format rat
》 p = R\b
p =
0
11/48
0
1/6
》 Z = null(R,'r')
Z =
-2/3 -2
-1/8 -1/8
1 0
0 1
》
Inverses
》 A = pascal(3)
A =
1 1 1
1 2 3
1 3 6
》 d = det(A)
d =
1
》 X = inv(A)
X =
3 -3 1
-3 5 -2
1 -2 1
》 B = magic(3)
B =
8 1 6
3 5 7
4 9 2
》 d = det(B)
d =
-360
》 X = inv(B)
X =
53/360 -13/90 23/360
-11/180 1/45 19/180
-7/360 17/90 -37/360
》 A = pascal(6)
A =
1 1 1 1 1 1
1 2 3 4 5 6
1 3 6 10 15 21
1 4 10 20 35 56
1 5 15 35 70 126
1 6 21 56 126 252
Cholesky Factorization
》 R = chol(A)
R =
1 1 1 1 1 1
0 1 2 3 4 5
0 0 1 3 6 10
0 0 0 1 4 10
0 0 0 0 1 5
0 0 0 0 0 1
》 B = magic(3)
B =
8 1 6
3 5 7
4 9 2
LU Factorizaion
》 [L,U] = lu(B)
L =
1.0000 0 0
0.3750 0.5441 1.0000
0.5000 1.0000 0
U =
8.0000 1.0000 6.0000
0 8.5000 -1.0000
0 0 5.2941
》 C = fix(10*rand(3,2))
C =
9 4
2 8
6 7
QR Factorization
》 [Q,R] = qr(C)
Q =
-0.8182 0.3999 -0.4131
-0.1818 -0.8616 -0.4739
-0.5455 -0.3126 0.7777
R =
-11.0000 -8.5455
0 -7.4817
0 0
》 [Q,R] = qr(C,0)
Q =
-0.8182 0.3999
-0.1818 -0.8616
-0.5455 -0.3126
R =
-11.0000 -8.5455
0 -7.4817
》 [Q,R,P} = qr(C)
??? [Q,R,P}
|
"]"、または "}" が見つからない、または表記が正しくありません
》 [Q,R,P] = qr(C)
Q =
-0.3522 0.8398 -0.4131
-0.7044 -0.5285 -0.4739
-0.6163 0.1241 0.7777
R =
-11.3578 -8.2762
0 7.2460
0 0
P =
0 1
1 0
》 [Q,R,P] = qr(C,0)
Q =
-0.3522 0.8398
-0.7044 -0.5285
-0.6163 0.1241
R =
-11.3578 -8.2762
0 7.2460
P =
2 1
返回