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!
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