Teljes Matlab script
(és live script)
kiegészítő függvényekkel.
Nézd meg Matlab live script html nézetben is!
Moore 1981, Principal Component Analysis in Linear Systems: Controllability, Observability, and Model Reduction
file: standard_1d_order_reduction.m
|author: Peter Polcz ppolcz@gmail.com |
Created on 2017. September 02.
Reviewed on 2017. September 24.
Automatically generated stuff
global SCOPE_DEPTH
SCOPE_DEPTH = 0;
detT = 0;
while ~(0 < detT && detT <= 2)
T = randn(4);
detT = det(T);
end
T, detT
T =
-1.5538 2.0288 -1.3990 -0.9801
-0.3543 -0.3672 1.3149 1.8573
0.4342 -2.3638 0.4038 0.3095
-0.1015 0.7299 -0.3442 -0.4891
detT =
0.4459
A = [
1 0 1 0
1 1 1 1
0 0 1 0
0 0 1 1
] .* randn(4);
B = [
1
1
0
0
] .* randn(4,1);
C = [ 1 0 1 0 ] .* randn(1,4);
A = T*A/T;
B = T*B;
C = C/T;
D = 0;
rtol = 1e-10;
pcz_display(A,B,C)
A [4x4] =
-0.6634 0.2711 0.9518 6.2501
0.4037 -3.0293 -4.0147 -15.8634
0.0011 -0.2817 -1.2165 -5.4682
-0.0914 0.6003 1.0347 4.3345
B [4x1] =
0.1101
0.3079
0.5817
-0.1964
C [1x4] =
-0.0378 2.3169 2.9178 10.7207
Cn = ctrb(A,B), rank(Cn,rtol)
On = obsv(A,C), rank(On,rtol)
Cn =
0.1101 -0.6636 0.2104 -0.2533
0.3079 -0.1077 0.1202 -0.0642
0.5817 0.2798 0.0977 0.0569
-0.1964 -0.0747 -0.0383 -0.0119
ans =
2
On =
-0.0378 2.3169 2.9178 10.7207
-0.0164 -1.4153 -1.7941 -6.4771
0.0296 0.9002 1.1469 4.0848
-0.0284 -0.5899 -0.7542 -2.6605
ans =
2
[U,Sigma,~] = svd(Cn);
XC_ = U(:,1:rank(Sigma,rtol))
% Alternatively:
% Xcx = orth(Cn)
XC_ =
0.8548 0.4172
0.0773 0.4843
-0.4936 0.7262
0.1405 -0.2530
[~,Sigma,V] = svd(On);
X_o = V(:,rank(Sigma,rtol)+1:end)
% Alternatively:
% Xx_2 = null(On)
X_o =
0.4040 -0.5014
-0.8874 -0.3230
-0.0672 0.7892
0.2115 -0.1468
XCo = intersection_of_subspaces(XC_',X_o')';
XCo_ORTH = null(XCo');
XCO = intersection_of_subspaces(XCo_ORTH', XC_')'
XCO =
1.0000
0.6694
0.6763
-0.2524
U = orth(XCO);
H = tf(ss(A,B,C,D));
H_min = minreal(H)
H_min =
0.3008
----------
s + 0.6949
Continuous-time transfer function.
We do not need to use minreal.
A_ = U'*A*U;
B_ = U'*B;
C_ = C*U;
D_ = D;
tf(ss(A_,B_,C_,D_))
ans =
0.3008
----------
s + 0.6949
Continuous-time transfer function.
The transformation matrix is returned by function minreal.
sys = ss(A,B,C,D);
[sysmin,S] = minreal(sys);
Kalman_decomp_A = S*A/S
3 states removed. Kalman_decomp_A = -0.6949 -0.0000 6.9603 0.1936 -0.8157 0.4271 -10.9286 -0.9284 -0.0000 0.0000 -0.4278 -0.0000 -0.0000 -0.0000 14.1056 0.1208