Defining a symbolic function with an integral
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I'm trying to define a symbolic function to represent the continuous time Fourier transform given by,

with the following code:
syms f;
CFTx(f) = int(x(t)*exp(-1i*2*pi*f*t), t, -Inf, Inf);
However, when I attempt to evaluate CFTx(s) at a some point s, say s = 10 the following is returned (directly from my command window):
CFTx(10)
ans =
int(exp(-pi*t*20i)*(5*cos(15*pi*t) + 2*sin(12*pi*t) + 5*exp(-(t - 25)^2/2)), t, -Inf, Inf)
I have tried evaluating this expression using the subs() function but so far have not had any luck.
Any advice is much appreciated.
0 个评论
回答(1 个)
Star Strider
2017-3-31
Your approach is correct, Your implementation needs to substitute the limits of integration with symbolic variables you can then substitute later.
Example —
syms f t T
x(t) = (5*cos(15*pi*t) + 2*sin(12*pi*t) + 5*exp(-(t - 25)^2/2));
CFTx(f) = int(x(t)*exp(-1i*2*pi*f*t), t, -T, T);
CFTx(f,T) = simplify(CFTx, 'Steps',20)
Then substitute for appropriate values of ‘f’ and ‘T’.
2 个评论
Star Strider
2017-3-31
My pleasure!
Most likely, you cannot have infinite limits, especially with a time-domain function that is periodic and may have an arbitrary value at ±Inf. I would choose a finite value for ‘T’, and then choose a frequency for the evaluation. Note that ‘pure’ periodic functions ‘exist’ in the Fourier transform only at the individual frequencies at which they are defined. They do not exist elsewhere.
I would do this:
a = simplify(subs(CFTy(s,T), [s], [10]), 'Steps',20)
and then substitute a finite value of ‘T’.
If you want to get the Fourier transform with infinite limits, use the Symbolic Math Toolbox fourier function:
Y(w) = fourier(y, t, w);
Y(w) = simplify(Y, 'Steps',20)
Y(w) =
5*pi*(dirac(w - 15*pi) + dirac(w + 15*pi)) - pi*(dirac(w - 12*pi) - dirac(w + 12*pi))*2i + 5*2^(1/2)*pi^(1/2)*exp(- (w + 25i)^2/2 - 625/2)
The dirac functions are due to the periodic functions existing only at those frequencies.
Plot or evaluate ‘Y(w)’ at the values of ‘w’ (‘omega’ or 2*pi*f) you want.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!