PLOTTING STEP RESPONSE OF TRANSFER FUNCTION USING FOURIER TRANSFORM

i am not getting the desired output from this code! can anyone help me with it??
the transfer function is in fourier domain!!
clc;
clear all;
syms t;
G = tf([1], [1 0.9 5]);
[num,den] = tfdata(G);
syms s
G_sym = poly2sym(cell2mat(num),s)/poly2sym(cell2mat(den),s)
G_sym=subs(G_sym,s,0.1*1i)
Y_four_sym = G_sym/s; % U(s) = 1/s for the unit step
y_time_sym(t) = ilaplace(Y_four_sym,t);
t=0:0.001:10;
plot(t,y_time_sym(t)

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日

0 投票

There are some issues in your code, compare it with the following code
G = tf(1, [1 0.9 5]);
[num,den] = tfdata(G);
syms s t
G_sym = poly2sym(num{:},s)/poly2sym(den{:},s);
Y_four_sym = G_sym/s; % U(s) = 1/s for the unit step
y_time_sym(t) = ilaplace(Y_four_sym,t);
T=0:0.001:10;
plot(T,y_time_sym(T))

11 件のコメント

AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
i want it in fourier domain!
not s domain
i have subsitute s= i* omega in my code to convert it into fourier domain
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
your answer is correct for laplace domain
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
Ok. This following code how to do it using the fourier domain
clear
G = tf(1, [1 0.9 5]);
[num,den] = tfdata(G);
syms s w t
G_sym = poly2sym(num{:},s)/poly2sym(den{:},s);
G_sym=subs(G_sym,s,1i*w); % s = 1i*w for fourier domain
Y_four_sym = G_sym*(1/(1i*w) + pi*dirac(w)); % U(jw) = 1/(1i*w) + pi*dirac(w) for the unit step
y_time_sym(t) = ifourier(Y_four_sym,t);
y_time_sym = matlabFunction(y_time_sym); % converted to function handle to speed up computation
T=0:0.001:10;
plot(T,y_time_sym(T))
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
thank-you! can u explain this line of code please
Y_four_sym = G_sym*(1/(1i*w) + pi*dirac(w));
i didnt get y u took pi*dirac(w)?
also what will be the code for impulse response?
Y_four_sym = G_sym*(1/(1i*w) only here i have to make chages right?
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
also u have not defined omega for your code?
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
your code is not working for third order transfer function?
clear
G = tf(1, [1 6 14 24]);
[num,den] = tfdata(G);
syms s w t
G_sym = poly2sym(num{:},s)/poly2sym(den{:},s);
G_sym=subs(G_sym,s,1i*w); % s = 1i*w for fourier domain
Y_four_sym = G_sym*(1/(1i*w) + pi*dirac(w)); % U(jw) = 1/(1i*w) + pi*dirac(w) for the unit step
y_time_sym(t) = ifourier(Y_four_sym,t);
y_time_sym = matlabFunction(y_time_sym); % converted to function handle to speed up computation
T=0:0.001:10;
plot(T,y_time_sym(T))
Unrecognized function or variable 'w'.
Error in
symengine>@(t)(pi./2.4e+1+(pi.*sign(t))./2.4e+1-fourier(w./(w.*1.4e+1i-w.^2.*6.0-w.^3.*1i+2.4e+1),w,-t).*2.5e-1i-fourier(1.0./(w.*1.4e+1i-w.^2.*6.0-w.^3.*1i+2.4e+1),w,-t).*(7.0./1.2e+1)+fourier(w.^2./(w.*1.4e+1i-w.^2.*6.0-w.^3.*1i+2.4e+1),w,-t)./2.4e+1)./(pi.*2.0)
Error in Untitled3 (line 11)
plot(T,y_time_sym(T))
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
AAYUSH, the term (1/(1i*w) + pi*dirac(w)) is the Fourier transform of unit step function, pi*dirac(w) term is also included in its Fourier transform. Dirac function is also commonly known as impulse function. As you know that in Fourier domain, Y(iw) = G(iw)X(iw), so we multiply Fourier transform of transfer function with the Fourier transform of unit step.
If you want impulse response, then you should multiply G_sym with 1 since the Fourier transform of impulse signal is 1.
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
okay thanks alot! your matlab code is not working for third order transfer function?
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
AAYUSH, I tried the code with the third-order system. The problems happen because MATLAB's symbolic engine is not able to calculate the inverse Fourier transform of the output transfer function. The solution does exist: https://www.wolframalpha.com/input/?i=inverse+transform+of+%28pi*dirac%28w%29+-+1i%2Fw%29%2F%28-+w%5E3*1i+-+6*w%5E2+%2B+w*14i+%2B+24%29. You can consider it a limitation of MATLAB's symbolic engine.
AAYUSH MARU
AAYUSH MARU 2020 年 4 月 5 日
is there any other way to solve it?
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
By "solving" if you mean that finding the response of the system, then there are other methods. But if you specifically want to solve it with Fourier transform, then it probably not be possible in MATLAB.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2020 年 4 月 5 日

コメント済み:

2020 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by