how to code transfer function
8 views (last 30 days)
Paul on 22 Sep 2022
Edited: Paul on 22 Sep 2022
There seems to be two questions in this Question.
The first question is: How to plot the transfer function. For values of tau0 and tau1, the transfer function from delta_c to delta is
H = tf(1,[tau1 1],'InputDelay',tau0);
The concept of "plot the transfer function" is ambiguous. Typical plots of a transfer function might be
What kind of plot is desired?
Or, if you really want to plot the actuator position in response to an actuator command (which isn't really "plot the transfer function"), then we need to define the actuator command of interest as a function of time and then use functions like step or lsim as apprropriate for the specific actuator command input of interest.
The second question is how to add those actuator dynamics to the simulation. For constant actuator command inputs, and assuming that the actuator commands are zero for t < 0 (i.e., we are injecting a step command into the actuator) the approach would be as follows. Referring to the code in this comment ...
Add three additional elements to the state vector, y. These will be the values of de, da, and dr. Make sure to initialize these values in y0
In function STOL_Eom:
Extract de, da, and dr from the state vector.
dec = de0*(t >tau0). Note that this approach is a little loose. Technically, we'd have to integrate from t = 0 to t = tau0, stop the simulation, and then restart it. But we can try to make this a little simpler, assuming that tau0 is reasonably small as would normally be the case for an actuator.
dedot = (dec - de) / tau1
Repeat for da and dr.
Add dedot, dadot, and drdot to the end of the xdot vector
In the main code, call ode45 with with additional option of InitialStep = tau0. See ode45 to see how to use the odeset function to specify this option.
The idea here is that ode45 will hopefully take a small first step from t = 0 to t = tau0 to catch the step change in the actuator commands. This can be checked in the t vector after the simulation completes.This approach is a bit loose, but may be sufficient for your needs. If it doesn't work as well as you'd like, come back and we can address this issue a bit better.
Based on the structure of the code, I guess tau0 and tau1 would be added to the global variable list with values assigned in the main script.
More Answers (1)
Sam Chak on 19 Sep 2022
Try something like this:
tau0 = 2;
tau1 = 3;
Gp = tf(1, [tau1 1],'InputDelay', tau0)
For more info, please check out: