Defining a symbolic function with an integral

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.

回答 (1 件)

Star Strider
Star Strider 2017 年 3 月 31 日

0 投票

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 件のコメント

David Beallor
David Beallor 2017 年 3 月 31 日
編集済み: David Beallor 2017 年 3 月 31 日
Unfortunately I'm still seeing the same results. Here's my code:
syms t;
x(t) = 5*exp(-(t-25)^2/2);
n(t) = 5*cos(15*pi*t) + 2*sin(12*pi*t);
y(t) = x(t) + n(t);
syms s T;
CFTy(s) = int(y(t)*exp(-1i*2*pi*s*t), t, -T, T);
CFTy(s,T) = simplify(CFTy, 'Steps', 20);
a = subs(CFTy(s,T), [s T], [10, Inf]);
disp(a)
and here's the output...
int(exp(-pi*t*20i)*(5*cos(15*pi*t) + 2*sin(12*pi*t) + 5*exp(-(t - 25)^2/2)), t, -Inf, Inf)
Can you think of what else might be causing this?
Thanks a lot for your help!
Star Strider
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.

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

カテゴリ

質問済み:

2017 年 3 月 31 日

コメント済み:

2017 年 3 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by