This example shows how to compute a low-order approximation in two ways and compares the results.
By default, balred discards the states with that make the smallest contribution to system behavior, altering the remaining states to preserve the DC gain of the system. Setting the StateElimMethod option to Truncate causes balred to discard low-energy states without altering the remaining states. Which method you choose depends upon what dynamics are important to your application. In general, preserving DC gain comes at the expense of accuracy in higher-frequency dynamics. Conversely, state truncation can yield more accuracy in fast transients, at the expense of low-frequency accuracy.
In this example, compare the two methods of computing a reduced-order approximation of the following closed-loop system from r to y.
Create the closed-loop model from r to y.
G = zpk([0 -2],[-1 -3],1); C = tf(2,[1 1e-2]); T = feedback(G*C,1)
T = 2 s (s+2) -------------------------------- (s+0.004277) (s+1.588) (s+4.418) Continuous-time zero/pole/gain model.
T is a third-order system that has a near pole-zero cancellation close to = 0. Therefore, it is a good candidate for order reduction by approximation.
Compute two second-order approximations to T, one that preserves the DC gain and one that truncates the lowest-energy state without changing the other states.
matchopt = balredOptions('StateElimMethod','MatchDC'); truncopt = balredOptions('StateElimMethod','Truncate'); Tmatch = balred(T,2,matchopt); Ttrunc = balred(T,2,truncopt);
Use balredOptions to specify the approximation method.
Compare the frequency responses of the approximated models.
bodeplot(T,Tmatch,Ttrunc) legend('Original','DC Match','Truncate')
The truncated model Ttrunc matches the original model well at high frequencies, but differs considerably at low frequency. Conversely, Tmatch yields a good match at low frequencies as expected, at the expense of high-frequency accuracy.
You can also see the differences between the two methods by examining the time-domain response in different regimes. Compare the slow dynamics by looking at the step response of all three models with a long time horizon.
stepplot(T,Tmatch,'r--',Ttrunc,1000) legend('Original','DC Match','Truncate')
As expected, on long time scales the DC matched approximation Tmatch is a good match to the original model.
Compare the fast transients in the step response.
stepplot(T,Tmatch,'r',Ttrunc,'g--',1) legend('Original','DC Match','Truncate')
On short time scales, the truncated approximation Ttrunc provides a better match to the original model. Which approximation method you should use depends on which regime is most important for your application.