getLoopTransfer is giving the same open loop transfer functions for two different systems
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
I have two separate systems and I am using slLinearizer and getLoopTransfer function to get the open loop transfer functions at the input of the plant (u) for both the systems. Although, the plant dynamics are same, but the controllers are designed differently. Still, getLoopTransfer function gives the same open loop function for both the systems.
CL_lqr = slLinearizer(mod_lqr);
addPoint(CL_lqr,'u')
Li_lqr = getLoopTransfer(CL_lqr, 'u', -1);
CL_lqg = slLinearizer(mod_lqg);
addPoint(CL_lqg,'u')
Li_lqg = getLoopTransfer(CL_lqg, 'u', -1); % result same as Li_lqr

System 2:

When I manually open the loop at 'u' for the 2nd system and linearize it, the result is a different open loop transfer function which seems correct.
Li_lqg = linearize(mod_lqg);

What could be the reason for the difference in the results? I have tried different ways of troubleshooting, I think getLoopTransfer function works differently than linearizing the model by putting in and out ports.
Accepted Answer
Paul
on 30 Sep 2023
Hi Janki,
I'd have to go through the math on the two calls to getLoopTransfer to determine if that result makes sense. Offhand, it doesn't sound like those two results should be the same, unless the estimator gain matrix, L, in the Kalman Filter block is zero (I'm assuming that block is really an ordinary Luenberger observer). Can you show a screen capture of the block paramters dialog for the Kalman Filter block?
The "manual" approach on the call to linearize is not the same as the call to getLoopTransfer on CL_lqg. The latter puts the analysis point at the output of the sum junction to the left of the node that branches off to the Kalman Filter block.
13 Comments
Janki Kaushal
on 30 Sep 2023
Hi Paul,
Thanks for your answer. I put the in and out ports at the output of the sum junction to the left of the node and linearized the model and it indeed matches with your explanation about the getLoopTransfer function. Yes, it is an ordinary state estimator, I get the gains using the kalman function in MATLAB.

How could I use the getLoopTransfer function to break the loop to the right of the node instead?
Paul
on 30 Sep 2023
"How could I use the getLoopTransfer function to break the loop to the right of the node instead? "
Put a gain block with a gain of 1 at the input to the plant to the right of the node that branches off to the Kalman Filter block. Set the name of the signal output from the gain block to 'u'.
So now all three cases yield the same result? I'll have to think about that some more as it's still not clear to me that should be the case for the problem as described.
Paul
on 30 Sep 2023
Having thought about it some more, I now think that breaking the loop to the left of that node will yield the same OL transfer function Li_lqg as is Li_lqr.
Janki Kaushal
on 30 Sep 2023
Hi Paul,
"How could I use the getLoopTransfer function to break the loop to the right of the node instead? "
I believe my original query is solved with your answer to the above question. Could you explain to me how breaking the loop to the left of the node will yield the same OL functions?
It can be proved symbolically.
I just posted this question, wherein LHS is the symbolic form of Li_lqg and RHS is the symbolic form of Li_lqr, but assuming the integral gain is zero (becuase that loop is the same for both cases) and ignoring the state feedback gain, because that just premultiplies both expressions.
I think there should be a more elegant approach than I posted there. I'm sure there is, it's just a matter of finding and applying the proper matrix identities.
Janki Kaushal
on 30 Sep 2023
Okay, makes sense. Thank you for your help.
Janki Kaushal
on 30 Sep 2023
I have one more question if you could help me with it. When I break the loop at the output n_z for both the systems, the loop transfer functions are the same. Why is that? I am attaching a snapshot of the result. The above transfer function is for the LQG system and the one below is for the LQR.

Paul
on 30 Sep 2023
Can you save to a .mat file the A,B,C,D matrices of the plant, the state feedback gain K, the estimator gain L, and the integral gain Ki and then upload the .mat file using the paperclip icon on the Insert ribbon? I'd like to try to recreate your results.
Janki Kaushal
on 30 Sep 2023
Yes, here you go.
I'm not sure I'm modeling the system correctly, but as I've done it I don't see the same open-loop transfer function at n_z for the two implementations. Do any of these results match yours?
load mydata
whos
Name Size Bytes Class Attributes
A 3x3 72 double
B 3x1 24 double
C 2x3 48 double
D 2x1 16 double
K 1x3 24 double
Ki 1x1 8 double
L 3x2 48 double
ans 1x35 70 char
cmdout 1x33 66 char
System 1 in the question shows the plant has four outputs. It looks like the first three outputs are the state variables q-pitch rate, alpha - angle-of-attack, and delta_e - elevon deflection. However, the C matrix here only indicates two outputs?
C
C = 2×3
0.1351 9.9137 0.1350
1.0000 0 0
I'll assume that these outputs are y (N_z?) and q and I'll augment the plant outputs to include the state variables.
plant = ss(A,B,[eye(3); C],[zeros(3,1) ; D],'InputName','u','OutputName',{'x1' 'x2' 'x3' 'n_z' 'q'});
gain = ss(1,'InputName','uc','OutputName','u');
Kc = ss(K,'InputName',{'x1' 'x2' 'x3'},'OutputName','Kx');
I = tf(Ki,[1 0],'InputName','e','OutputName','xi');
sum1 = sumblk('uc = xi - Kx');
sum2 = sumblk('e = r - n_z');
CL_lqr = connect(plant,gain,Kc,I,sum1,sum2,'r','n_z',{'u' 'uc' 'n_z'});
Warning: The following block outputs are not used: q.
Li_lqr = getLoopTransfer(CL_lqr,'n_z',-1);
estimator = ss(A-L*C,[B L],eye(3),zeros(3),'InputName',{'uc' 'n_z' 'q'},'OutputName',{'xhat1' 'xhat2' 'xhat3'});
Kc = ss(K,'InputName',{'xhat1' 'xhat2' 'xhat3'},'OutputName','Kxhat');
sum1 = sumblk('uc = xi - Kxhat');
CL_lqg = connect(plant,gain,Kc,I,sum1,sum2,estimator,'r','n_z',{'u' 'uc' 'n_z'});
Warning: The following block outputs are not used: x1,x2,x3.
Li_lqg = getLoopTransfer(CL_lqg,'n_z',-1);
Compare closed-loop transfer functions
zpk(minreal(ss(CL_lqr)))
ans =
From input "r" to output "n_z":
-1.9232 (s+17.17) (s-21.08)
------------------------------------------
(s+12.71) (s+2.557) (s^2 + 4.184s + 21.42)
Continuous-time zero/pole/gain model.
zpk(minreal(ss(CL_lqg)))
3 states removed.
ans =
From input "r" to output "n_z":
-1.9232 (s-21.08) (s+17.17)
------------------------------------------
(s+12.71) (s+2.557) (s^2 + 4.184s + 21.42)
Continuous-time zero/pole/gain model.
minreal(zpk(CL_lqg))
ans =
From input "r" to output "n_z":
-1.9232 (s-21.08) (s+17.17)
------------------------------------------
(s+2.557) (s+12.71) (s^2 + 4.184s + 21.42)
Continuous-time zero/pole/gain model.
figure
step(CL_lqr,CL_lqg)

Compare open loop transfer functions at the n_z feedback.
figure
bode(Li_lqr,Li_lqg)

zpk(minreal(ss(Li_lqr)))
ans =
From input "n_z" to output "n_z":
-1.9232 (s+17.17) (s-21.08)
----------------------------------
s (s+12.91) (s^2 + 6.541s + 35.28)
Continuous-time zero/pole/gain model.
zpk(minreal(ss(Li_lqg)))
1 state removed.
ans =
From input "n_z" to output "n_z":
-4.5767 (s-21.08) (s+17.17) (s^2 + 7.573s + 71.12)
--------------------------------------------------------
s (s+14.87) (s^2 + 5.29s + 30.98) (s^2 + 24.59s + 178.4)
Continuous-time zero/pole/gain model.
Thank you for implementing this example. I am getting the same results and your assumption about augmenting the C matrix is also correct. Sorry I did not specify that in my data.
Here, I see that the loop is broken at the n_z feedback (to the kalman filter) in the LQG system. However, I am calculating the OL transfer function at the n_z feedback to the reference. Consider the following image.

If I calculate the OL transfer functions at 'n_z' and 'nz_fb', I get the following results.

I want to know why we get the same results for both the systems when we calculate OL transfer functions at the n_z feedback to the reference. I found an explanation and it says this is because we are essentially isolating the reference tracking loop when we open it and so the behaviour of the controller (whether LQR or LQG) is not manifested in the OL transfer function.
Could you verify this explanation? Also, the inner loops are still closed, then why do we not see the behaviour of the controller?
Paul
on 1 Oct 2023
Consider the plant and estimator dynamics written as follows
xdot = A*x + B*u
y = C*x
ye = y - yhat
xhatdot = A*xhat + B*u + L*ye
yhat = C*xhat
If the input signal, u, is the exact same input that drives the plant AND the initial conditions on x and xhat are the same, then it must be the case that:
x = xhat
y = yhat
i.e., the estimated state output of the estimator is exactly the same as the state output of the plant and the output estimation error, ye, is zero. That's why in the initial problem breaking the loop the left of the node on the input path yielded the same results for both systems. On the output side, the same thing happens when we break the loop at the n_z signal as long as the nz_fb signal is input to the filter. But, when we break the loop at nz_fb, we get a very different system
ye = [0 1]*y - yhat
xhatdot = A*xhat + B*u + L*ye
In this case, the estimator gain is multiplying a non-zero signal (becuase yhat(1) ~= 0) and that will introduce additional dynamics into the open loop system.
If you modify the Simulink model for the lqg case to explicity implement the esimator dynamics as shown above, you can probe the individual signals (y, yhat, ye) and verify. Alterntatively, you could go through all of the block diagram algebra for both cases.
Disclaimer: All of the above is only based on thinking about the problem, strongly advise additional simulation/analysis to verify.
This explanation is clear to me. Thank you for all your help, Paul!
More Answers (0)
Categories
Find more on State-Space Control Design in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)