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

13 views (last 30 days)
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 Comments
Si eun Jung
Si eun Jung on 6 Jun 2020
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...

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 6 Jun 2020
F = @(t) (t < .98) * 3 +(t > .98) * 6
fplot(F,[0,2])
  7 Comments
Gyanu Gautam
Gyanu Gautam on 8 Jun 2020
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 :)
Paul
Paul on 8 Jun 2020
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?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!