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
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
David Beallor
2017년 3월 31일
편집: David Beallor
2017년 3월 31일
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.
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!