How can I create a step response with the following unit step function as input?

input : F
when (0<t), F = 3
when (0.98<t) = 6
I want to make step response with that unit step function as input in matlab...
please help me..

2 commentaires

And how is the transfer function defined?
TF is
1/(s^2+2*zeta*w_n*s+w_n^2)!!
w_n = 10, zeta = 0.2
so, I made that code
clc;
clear all;
close all;
w_n = 10;
zeta = 0.2;
t=0:0.01:10;
F(0<t) = 3;
F(0.98<t) = 6;
X = tf([F.*w_n^2],[1 2*zeta*w_n w_n^2])
step(X,t)
but I finally failed...

Connectez-vous pour commenter.

 Réponse acceptée

F = @(t) (t < .98) * 3 +(t > .98) * 6
fplot(F,[0,2])

7 commentaires

You will get even more refined plot of step function if you use the following code:
F = @(t) (t < .98) * 3 +(t >= .98) * 6
fplot(F,[0,2])
I just tweaked a liitle bit of your code.
madhan ravi: Thank you ;)
TF is
1/(s^2+2*zeta*w_n*s+w_n^2)!!
w_n = 10, zeta = 0.2
so, I made that code...
clc;
clear all;
close all;
w_n = 10;
zeta = 0.2;
t=0:0.01:10;
F(0<t) = 3;
F(0.98<t) = 6;
X = tf([F.*w_n^2],[1 2*zeta*w_n w_n^2])
step(X,t)
but I finally failed...
w_n = 10;
zeta = 0.2;
t = 0:0.01:10;
X = tf(w_n^2,[1 2*zeta*w_n w_n^2]);
F = @(t) (t < .98) * 3 +(t >= .98) * 6
subplot(2,1,1)
plot(t,F(t))
title('Step Input')
subplot(2,1,2)
lsim(X,F(t),t)
oh my god.... youre genius....
Thank you soooooo much...
Madhan's code gives the expected result. However, keep in mind that it only worked because lsim was able to detect the jump at t = 0.98 and use an appropriate approximation in its conversion of X to discrete time. So be careful using lsim. doc lsim for more information.
You can generate the step response for X using:
y = step(X,t)
Then you can use y, and y only, to compute the final result that you need. If all you wanted was the plot of the final result, then madhan's approach is fine. But if you're doing this for a class where you need to understand the fundametals of LTI systems, you should try it this way as well.
I have a doubt here.
How can we plot step response for the "specified step input" from MATLAB-inbuilt 'step()' function.
Here the step input specified is:
F = 3 when (0<t)
and F = 6 when (0.98<t).
While the default step() function will plot the step response of unit step function:
U = 1 when (0<t)
U = 0 otherwise.
Also, doc lsim says it simulates time response of both continuous and discrete systems.
BTW, Beautiful solution Madhan Ravi :)
The original definition of the input F was ill posed. What is F(2) supposed to be?
Clearly 0 < 2, so F = 3.
But 0.98 < 2, so F = 6.
Because madhan's solution was accepted by the OP, we see that the input F is really supposed to be:
F(t) = 3 (0 <= t < 0.98)
F(t) = 6 (0.98 <= t).
Now we can define the unit step function U(t) as:
U(t) = 0 (t < 0)
U(t) = 1 (t >= 0) % note the >=
You are correct that the command
Y = step(X,t)
returns the output of the linear system with transfer function X in response to the unit step input U.
However, the actual input we care about, F, can be written in terms of U:
F(t) = 3*U(t) + 3*U(t - 0.98)
Therefore, the output that we care about, let's call it Z(t) is:
Z(t) = 3*Y(t) + 3*Y(t - 0.98).
So you only really need to compute Y once using the step command.
You're correct that lsim can accept either continous and discrete systems. Is that relevant to this discussion?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by