Professional Documents
Culture Documents
% System Initialization: For End
% System Initialization: For End
% System Initialization: For End
4-1
clear all
clc
% System Initialization
A=[0 1;0 0];
B=[0;1];
C=[1 0]; % The system matrix
Q=[8 0;0 256]; % contains Qv and Qd
R=1;
L=[sqrt(40) 16]';
% Real system
x0=[-1 1]';
x_est0=[0 0]';
sys=ss(A,B,C,0);
t=0:0.01:5;
for n=1:501
u(:,n)=0;
end
[y,t,xx]=lsim(sys,u,t,x0);
figure(1);
plot(t,xx(:,1),'r'),gtext('d(t)');hold on;
plot(t,xx(:,2),'r'),gtext('v(t)');
xlabel('time in second');
title('Uncompensated system');
hold on;
Anew=A-L*C;
% Bnew=L.*YY;
sys1=ss(Anew,L,C,0);
for n=1:501
u1(:,n)=y(n,1);
end
[y1,t,xx1]=lsim(sys1,u1,t,x_est0);
plot(t,xx1(:,1),'b-*'),gtext('d-estimate(t)');hold on;
plot(t,xx1(:,2),'b-o'),gtext('v-estimate(t)');
xlabel('time in second');
title('Uncompensated system');
Example 9.4-2
clear all
clc
fw=[];
for w=0.0001:0.01:10
fw=[fw 698*(1+36.54*w^2)/((1+12.18*w^2)^2)];
end
semilogx(0.0001:0.01:10,fw)
title('vertical wind gust spectral density')
xlabel('w(rad/sec)')
ylabel('Wind Gust speed density')
A=[-1.01887 0.90506 0.00441 0.02663 -0.00215;0.82225 -1.07741 -0.00356 -0.02152
-0.17555;0 0 0 1 0;0 0 -0.08230 -0.57370 0;0 0 0 0.57370 -20.2];
B=[0;0;0;0;20.2];
G=[0;0;0;1;0];
C=[15.87875 1.48113 0 0 0;0 1 0 0 0];
Q=10;
R=[1/20 0;0 1/60];
sys=ss(A,[B G],C,0);
[kest,L,P]=kalman(sys,Q,R,0);
Kalman function designs a Kalman state estimator given a state-space model of the plant and the
process and measurement noise covariance data. The Kalman estimator provides the optimal
solution to the following continuous or discrete estimation problems.