# I don't seem to understand the feedback function of matlab

12 views (last 30 days)
Richard Kolawole on 26 Oct 2021
Edited: Sam Chak on 27 Oct 2021 So I want to make y track the reference u through the controller C.
The closed loop transfer function of the following system would be = feedback(G*C,1), Lets say C(S) = or any controller of my choice
What I don't understand is how the reference U comes into play when using the feedback function. Like lets say my reference U is static and constant in time equal to 50. How do I make Y approach the value of 50 over time. I know the question might seem simple but I can't seem to find the answers I need anywhere.
U= 50;
G = tf([2 5 1],[1 2 3]);
C = tf([5,10],[1,10]);
sys = feedback(G*C,1);
sys represents the transfer function of the closed loop system, but having defined it, how do I make Y(S) approach U(s) over time? I couldn't seem find any matlab function to make Y tend to U.
Thank you very much !!
##### 1 CommentShowHide None
Sam Chak on 27 Oct 2021
Edited: Sam Chak on 27 Oct 2021
I'm unsure if the pendulum motion can be described by your . From your , if the order of the numerator is equal to the order of the denominator, then the direct transmission matrix D in the state space is non-zero .
Since your is stable, a direct input from will give a steady-state output. To ensure that converges to , the reference signal needs to be amplified by a gain of 3, or making .
So, in the open-loop config, , will approach to 50 over time if you set .
To implent the controller in the closed-loop config, and since the plant is already , you can design the controller as a pure integrator .
This will make the order of the denominator to be greater than the order of the numerator in the closed-loop transfer function. If is selected, then the closed-loop system becomes .
A prefilter can be added if you want to cancel out the zeros and this yields .

Paul on 26 Oct 2021
Edited: Paul on 26 Oct 2021
The feedback() function returns the LTI system with input u and output y. Other functions are used to determine the output of that system in response to specific or user defined inputs. Based on the question it sounds like you may be interested in step() or lsim()
doc step
doc lsim
##### 2 CommentsShowHide 1 older comment
Paul on 26 Oct 2021
Whether or not or how well the closed loop system tracks an arbitrary reference depends on the design of C(s) and what types of reference signals the design is supposed to track (steps, ramps, sinusoids, etc.). So now it sounds like the question is really about how to design of C(s), not the use of the feeback() function, which is not a design tool.
Let's look at the system posted in the question:
G = tf([2 5 1],[1 2 3]);
The Control System Toolbox offers functions to design compensators (disclaimer: I don't know much about these): link. For example, use pidtune() to design a PI compensator so that the closed loop will track a step reference input with zero steady state error
C = pidtune(G,'PI')
C = 1 Ki * --- s with Ki = 0.481 Continuous-time I-only controller.
Note that pidtune() decided the default design goals could be achieved with just integral control. Now check the output of the closed loop system in response to a step input
sys = feedback(G*C,1);
step(sys) As expected with integral control, the closed loop tracks the step reference with zero steady state error. However, C(s) will result in a non-zero steady state error to a reference ramp input
lsim(sys,0:.1:100,0:.1:100)
hold on;
plot(0:100,0:100,'r') Sam Chak on 27 Oct 2021
Edited: Sam Chak on 27 Oct 2021
I'll talk about the basic theory first. Take a simple pendulum for example, where its nonlinear equation of motion can be approximated by a linear time-invariant model with kg, m/s², m. (Also check if your pendulum complies with the standard model). The plant is given by .
For a 2nd-order system, we can first test if a PD controller gives a satifactory performance. If a PD controller is used ,
then the closed-loop system becomes ,
which can be rewritten as .
From the characteristic polynomial (denominator), we want to stabilize the pendulum according to the desired Hurwitz polynomial: .
The easiest way to obtain the values of α and β is to refer to some performance tables proposed by the control theorists. If you cannot find such tables, you can easily calculate them using the Binomial coefficient formula. For example, for 3rd-order systems, the formula gives and , and these Hurwitz coefficients will give a critically-damped response. In this example, we will take and , which will give a deadbeat response (Modern Control Systems by Dorf & Bishop).
Next, we have to determine based on the desired settling time using the formula where the normalized settling time for is 5 seconds. If s, then . Making the substitutions of α, β, into the Hurwitz polynomial, the control gains , and the time constant can be determined though solving some simple algebraic equations (for low order systems). This technique is similar to the Pole Placement.   In this example, the control gains , and the time constant are found as .
The closed-loop system is now stable ,
but we can easily add a pre-filter (after the reference signal ) to cancel out the zero (numerator) of , to revert the sign, and to maintain the DC gain of 1 .
Having that, this control configuration guarantees the plant output follows the reference signal and settles within 2 seconds .
Now, you can try applying this to your pendulum.

R2020b

### Community Treasure Hunt

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

Start Hunting!