how to plot function with a sine input in Matlab (not in simulink)
38 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Paulo Silva
2011-6-27
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 个评论
Geraint Bevan
2019-7-16
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)
更多回答(1 个)
Geraint Bevan
2019-7-16
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!