## Cannot plot Fourier Transform

on 12 Jun 2019
Latest activity Answered by David Goodmanson

### David Goodmanson (view profile)

on 12 Jun 2019
Hello. I want to compute and plot the fourier transform of a function with fourier(x) function in matlab. The function I am trouble with is (sin(2*t)/(pi*t))^2. It seems that it's fourier transform cannot be computed. This is the code that I have written:
clear;
clc;
syms t w
h = sin(4*(t-1))./(pi*(t-1));
figure
fplot(t, h)
H = fourier(h, t, w);
magnitude_H = abs(H);
phase_H = angle(H);
figure
fplot(magnitude_H)
figure
fplot(phase_H)
% Define Input and calculate it's fourier transform
x = (sin(2*t)./(pi*t)).^2;
figure
fplot(t, x)
X = fourier(x, t, w);
figure
fplot(X)
% Calculate output in freq domain
Y = X*H;
figure
fplot(abs(Y));
y(t) = ifourier(Y, w, t)
figure
fplot(y)
this is the error:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your
function to return an output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/updateFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 237)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 192)
In fplot>vectorizeFplot (line 192)
In fplot (line 162)
In Untitled3 (line 23)
Warning: Error updating FunctionLine.
The following error was reported evaluating the function in FunctionLine update: Unable to convert
expression into double array.
Warning: Error updating FunctionLine.
The following error was reported evaluating the function in FunctionLine update: Unable to convert
expression into double array.
Is there a fix for my code?

R2018b