User`s guide

Table Of Contents
Kalman Filtering
9-55
Finally, close the sensor loop by connecting the plant output to the filter
input with positive feedback.
% Close loop around input #4 and output #2
SimModel = feedback(sys,1,4,2,1)
% Delete yv from I/O list
SimModel = SimModel([1 3],[1 2 3])
The resulting simulation model has as inputs and as outputs.
SimModel.input
ans =
'w'
'v'
'u'
SimModel.output
ans =
'y'
'y_e'
You are now ready to simulate the filter behavior. Generate a sinusoidal input
and process and measurement noise vectors and .
t = [0:100]';
u = sin(t/5);
n = length(t)
randn('seed',0)
w = sqrt(Q)*randn(n,1);
v = sqrt(R)*randn(n,1);
Now s imulate with lsim.
[out,x] = lsim(SimModel,[w,v,u]);
y = out(:,1); % true response
ye = out(:,2); % filtered response
yv = y + v; % measured response
y
v
y
v
wvu
,,
yy
e
,
u
w
v