how to code transfer function

8 views (last 30 days)
Cesar Cardenas
Cesar Cardenas on 19 Sep 2022
Commented: Paul on 26 Sep 2022
Hi, I would like to know how to code and plot this tf:
This in my attempt;
d = (e^-(t*s)/t1*s + 1)*dc;
not sure about it, any help will be greatly appreciated. Thanks much.
  10 Comments

Sign in to comment.

Accepted Answer

Paul
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
bode(H)
impulse(H)
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.
Compute:
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.
  18 Comments
Paul
Paul on 26 Sep 2022
The call in GenericFixedWingEOM should be to "doublet", not "double." I realize you copied exactly what I typed in that comment (since corrected).
What is your definition of a doublet?
I assumed that it's some sort of actuator command defined as a function of time. For example, step the actuator command to 0.001 for 1 second, down to -0.001 for 1 second, and back to zero.
t = 0:.001:3;
figure
plot(t,doublet(t))
ylim([-1.1 1.1]*1e-3)
xlabel('Time (sec)');
ylabel('Actuator Command')
Perhaps my assumption was incorrect.
function dc = doublet(t)
dc = 0.001*(t < 1) - 0.001*(t >=1 & t < 2) + 0*(t >= 2);
end

Sign in to comment.

More Answers (1)

Sam Chak
Sam Chak on 19 Sep 2022
Try something like this:
tau0 = 2;
tau1 = 3;
Gp = tf(1, [tau1 1],'InputDelay', tau0)
Gp = 1 exp(-2*s) * ------- 3 s + 1 Continuous-time transfer function.
For more info, please check out:

Community Treasure Hunt

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

Start Hunting!