How is the function FEEDBACK implemented in Matlab?

3 views (last 30 days)
Hello together,
I used the function »feedback« to generate a closed-loop system, which worked well. Now I am trying to understand, how this function is mathematically implemented in Matlab. There are a lot of information’s, how to use the function, but I didn't find anything which describes how it’s working and implemented mathematically. Does this function use iterative every sample from the output and add it to the input?
Thank you!

Accepted Answer

Ameer Hamza
Ameer Hamza on 16 Oct 2020
No, it does not use any input and output data points of systems to construct a feedback system. There is a closed-form expression to create feedback from two systems. Read here: https://en.wikipedia.org/wiki/Closed-loop_transfer_function and https://www.tutorialspoint.com/control_systems/control_systems_feedback.htm. It uses the transfer function of these two blocks and uses the expression to create a feedback system.
  3 Comments
Ameer Hamza
Ameer Hamza on 16 Oct 2020
Yes, there is a bit of a difference. If you simplify the result of G/(1+GH), it will be the same as feedback(). You can see in that example, both numerator and denominator are multiplied by the same factor, which adds poles and zeros at the same locations.
Paul
Paul on 8 Aug 2024
As of R2022a,
For the command:
%C = feedback(G,H)
If G and H are both SISO tf objects, then C is computed with polynomial algebra based on the numerator and denominator of G and H respectively.
If G and H are both tf objects, but either is not SISO, then both are converted to ss objects, C is formed from the state space matrices, and then converted back to tf.
If G and H are both zpk objects, they are both converted to ss, C is formed from the state space matrices, then converted back to zpk.
If G and H are both ss objects, then form C from the state space matrices.
If one of G or H is zpk and the other tf, then the tf is converted to zpk, and proceed as above (returns zpk).
If one of G or H is ss, then convert the other to ss and proceed as above (returns ss).
To follow up on @Ameer Hamza's answer, the expression
%G/(1 + G*H)
is implemented as a sequence of algebraic operations. Consider G(s) and H(s) defined as follows:
G = zpk(-1,[-2,-3],1); H = zpk([],-1,1);
Walk through the algebra, step by step
temp = G*H
temp = (s+1) ----------------- (s+2) (s+3) (s+1) Continuous-time zero/pole/gain model.
temp = 1 + temp
temp = (s+1) (s^2 + 5s + 7) -------------------- (s+2) (s+3) (s+1) Continuous-time zero/pole/gain model.
G/temp
ans = (s+1)^2 (s+2) (s+3) -------------------------------- (s+2) (s+3) (s+1) (s^2 + 5s + 7) Continuous-time zero/pole/gain model.
which is the same as
C = G/(1+G*H)
C = (s+1)^2 (s+2) (s+3) -------------------------------- (s+2) (s+3) (s+1) (s^2 + 5s + 7) Continuous-time zero/pole/gain model.
We see that clearing the polynomial fractions led to phantom poles and zero at s = -2 and s = -3.. We see that there is also a common pole/zero at s = -1, which still hanging around from the pole and zero at that location in H(s) and G(s) respectively.
Now, to "simplify" the result I assume that @Ameer Hamza means to use minreal
minreal(C,1e-7)
ans = (s+1) -------------- (s^2 + 5s + 7) Continuous-time zero/pole/gain model.
which gets rid of the poles/zeros at s = -2/-3, but also eliminates the pole/zero at s = -1 (which might or might not be a desirable result).
OTOH, feedback computes the result "directly," i.e., not as a sequence of algebraic steps
C = feedback(G,H)
C = (s+1)^2 -------------------- (s+1) (s^2 + 5s + 7) Continuous-time zero/pole/gain model.
and the pole/zero at s = -1 remains in the result, (which could subsequently be removed via minreal if so desired
minreal(C)
ans = (s+1) -------------- (s^2 + 5s + 7) Continuous-time zero/pole/gain model.
Note that minreal worked here with the default tolerance, which is considerably smaller than 1e-7 that was needed after the algebraic approach.
Moral of the story is: use feedback as recommended by Using FEEDBACK to Close Feedback Loops
Also, ss is preferred over zpk, and zpk is preferred over tf.

Sign in to comment.

More Answers (1)

Ntokozo
Ntokozo on 7 Aug 2024
Use MATLAB commands to find G(s) expressed as factors in the numerator divided by factors in the denominator.

Categories

Find more on Dynamic System Models in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!