PLEASE HELP!!!! PLOT STEP FUNCTION WITH DEFINED AMPLITUDE

Hello everyone,
I have a problem with plotting step function. I have a code about plotting a transfer function. I will add my code to show.
In my code, i want to change the default amplitude of transfer function. As I learned, Matlab has a default amplitude as 1. According to my research, there is a option about "Options for the step command". Here is the link: https://www.mathworks.com/help/control/ref/stepdataoptions.html#d123e129499
Here, I want to change my amplitude as 5. I think I might write opt = stepDataOptions('StepAmplitude',5);
But here there was a code which is [y,t] = step(sys,opt); and I dont get it what is the meaning of y and t. Why must we do smth like that?
And also I want to plot my transfer function after change the amplitude. And again, as my research, I think I must be write code as plot(t,y).
But why must we write (t,y) in the plot while we define [y,t]?
K_parameter = 1;
TL_parameter = 2;
TI_parameter = 3;
WN_parameter = 4;
t_parameter = 5;
zeta_parameter = 6;
F = K_parameter*tf([TL_parameter 1],[TI_parameter 1])*tf(1,[1/WN_parameter^2 2*zeta_parameter/WN_parameter 1]);
sys = F*exp(-t_parameter*tf('s'));
transfer_plot = stepplot(sys);
grid on
info = stepinfo(sys)
st = info.SettlingTime

 Accepted Answer

>[y,t] = step(sys,opt); Why must we do smth like that?
You don't have to do that. You can choose both way, with [y, t], or without [y, t].
  • if you choose with [y, t], step() gives you "Step Response Data", and it does not give you "Step Response Plots".
  • if you choose without [y, t], step() gives you "Step Response Plots", and it does not give you "Step Response Data".
You might see this example, but [y,t] = step(sys,opt); can be replaced with step(sys,opt);. You will get plot instead of [t, y] data.
opt = stepDataOptions('InputOffset',-1,'StepAmplitude',2);
[y,t] = step(sys,opt);
>But why must we write (t,y) in the plot while we define [y,t]?
Plot() is process for plot only and does not care about step function. So it needs (t, y) for data plot. If you choose step() without [y, t], you don't need using plot().

5 Comments

Am I understand correct? Can I just write this and it gives me step response with amplitude 5?
K_parameter = 1; TL_parameter = 2;TI_parameter = 3;WN_parameter = 4;t_parameter = 5; zeta_parameter = 6;
F = K_parameter*tf([TL_parameter 1],[TI_parameter 1])*tf(1,[1/WN_parameter^2 2*zeta_parameter/WN_parameter 1]);
sys = F*exp(-t_parameter*tf('s'));
opt = stepDataOptions('StepAmplitude',5);
plot(sys, opt)
I dont understand the " If you choose step() without [y, t], you don't need using plot()." Can you explain it again please?
And lastly, while we define [y,t] = step(sys,opt); here is y is meaning sys and t is defining by opt? or there is another meanings of these y and t?
Thank you again. I'm looking forward to your answer. :)
To illustrate what @Atsushi Ueno is saying, either use step() without output arguments to make the plot, or use step() with output arguments and then use plot() to plot the result yourself using those outputs. The plot will be the same either way.
% set up the model
K_parameter = 1; TL_parameter = 2;TI_parameter = 3;WN_parameter = 4;t_parameter = 5; zeta_parameter = 6;
F = K_parameter*tf([TL_parameter 1],[TI_parameter 1])*tf(1,[1/WN_parameter^2 2*zeta_parameter/WN_parameter 1]);
sys = F*exp(-t_parameter*tf('s'));
opt = stepDataOptions('StepAmplitude',5);
% Option 1 - call step without output arguments. step() will make the plot
step(sys,opt)
% Option 2 - call step with output argument. step() does not make the plot.
% use plot() to plot the result
[y,t]=step(sys,opt);
plot(t,y)
% Option 3 - Use either option 1 or option 2 without using stepDataOptions.
% Here's how to do it by calling step() without output arguments
step(5*sys)
Okay, i think i understand now. I mean there is 3 different way. I just dont exactly understand option 2.
[y,t]=step(sys,opt);
plot(t,y)
Here why we write y,t while defining and then write reverse as t,y during plotting?
And what is the meaning of y and t?
The doc pages will answer these questions:
doc step
doc plot

Sign in to comment.

More Answers (0)

Categories

Find more on Control System Toolbox in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 14 May 2021

Commented:

on 19 May 2021

Community Treasure Hunt

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

Start Hunting!