how to plot function with a sine input in Matlab (not in simulink)

38 ビュー (過去 30 日間)
Lokman Abdullah
Lokman Abdullah 2011 年 6 月 27 日
回答済み: Geraint Bevan 2019 年 7 月 16 日
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.

採用された回答

Paulo Silva
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
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
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')

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by