how to plot function with a sine input in Matlab (not in simulink)
38 views (last 30 days)
Show older comments
Lokman Abdullah
on 27 Jun 2011
Answered: Geraint Bevan
on 16 Jul 2019
we just type command 'step(function)' to plot a function with input step but How to plot a function that use sine as an input in Matlab.
0 Comments
Accepted Answer
Paulo Silva
on 27 Jun 2011
When you invoke the step function you are multiplying your function on the frequency domain by 1/s, the function you get from that operation is then converted to the time domain using the ilaplace function.
Now for you specific case you can first convert the function to the time domain using ilaplace and then multiply by sin(t).
For the plot make the t vector and use the plot function to plot the response
plot(t,f(t))
Example
syms s t
TFC=evalc('tf([1 1],[1 1 1 0])')
%subplot(211)
[a b] = strread(TFC, '%s %s', 'delimiter',char(10));
num=sym(char(a(2)));
den=sym(char(a(3)));
tft=ilaplace(num/den);
tt=0:0.01:10;
plot(tt,subs(tft,t,tt).*sin(tt))
title('f*sin(t)') %response to input sin(t)
ylabel('Amplitude')
xlabel('time')
1 Comment
Geraint Bevan
on 16 Jul 2019
The answer above is completely wrong.
Multiplying the inverse Laplace transform by a sine wave is not at all equivalent to applying a sine input to the system.
If you wish to use ilaplace to do this, you should apply the sine input in the 's' domain and then transform back into the time domain.
e.g.
syms s
G = 1/(1+s)
U = 4/(s^2+16) % sin(4t)
Y = G*U
y = ilaplace(Y)
More Answers (1)
Geraint Bevan
on 16 Jul 2019
Use the lsim function to apply an arbitrary input to a system.
G = tf(1,[1,1])
t = [0:0.01:10]
u = sin(t)
[y,t] = lsim(G,u,t)
plot(t,u,t,y)
legend('Input','Output')
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!