Taking fourier transform of a function using symbolic variable

1.8k Views Asked by At

MATLAB failed to compute the fft of this function:

syms t;
x= 1/(1+t^2);
X= fft(x)

And threw this error:

Undefined function 'fft' for input arguments of type 'sym'.

Why didn't it take the Fourier transform of the symbolic variable? I think it should because we may want to obtain the result as a symbolic value.

I also tried to solve the problem with non-symbolic variable.

t= -10:0.01:10;
x= zeros(2001);
x= 1/(1+t.^2);
fft(x)

this time my error is:

Matrix dimensions must agree.

However, they have the same dimensions. Where is my fault?

2

There are 2 best solutions below

0
On

The documantation on fft says:

Y = fft(X) computes the discrete Fourier transform (DFT) of X using a fast Fourier transform (FFT) algorithm.

Symbolic functions are continuous, not discrete. Hence, the algorithm fails.

With regards to your second question: use element-wise operators, by adding a dot:

t= -10:0.01:10;
x= zeros(2001);
x= 1./(1+t.^2);
fft(x)

MATLAB complains about matrix dimensions, because you are trying to divide a scalar (i.e. a 1 x 1 matrix) by a vector of length 2001. element-wise division solves that problem.

0
On

Source: http://www.mathworks.com/matlabcentral/newsreader/view_thread/315950

FFT is a method for numerical discrete Fourier Transform (DFT).

Basically, what you're asking doesn't make sense. FFT is designed to work numerically on discrete data (a sequence of numbers).

What you want is the Fourier Transform of your symbolic expression. For that, I believe you want fourier.