Chapter 1 Introduction
© National Instruments Corporation 1-17 Xmath Control Design Module
When you create the estimator system sys_est, you use the original
A matrix for the state-update equation, but you provide a zero external
input (a B matrix of zero). The output matrix is an identity matrix passing
back the three real state values and the three estimated state values as
output, again with no external input values affecting the output. Here you
use the optional system( ) keyword X0 to set the real state values to
[1,2,3] and the estimated state values to [–1,–2,–3].
By simulating with a general input over two seconds, you can see how long
it takes for the state values provided by the estimator to correct the incorrect
initial conditions and track the real state values.
[,,allStates]=names(sys_cl);
sys_est = system(A_cl, zeros(6,1), eye(6,6), ...
zeros(6,1),{x0 = [1,2,3,-1,-2,-3], ...
stateNames = allStates});
state_resp = sys_est*pdm(ones(100,1), 0:(2/99):2);
Plot the results, referring to Figure 1-10:
plot(state_resp,{strip=2,xlab="Time",
legend=["State","State estimate"]})
Even in the relatively short time span of this simulation, the estimates and
the real states quickly converge.