I want to plot the Fourier transform, using MATLAB, of data which is plotted with the following code:
x = -2:0.01:2; % position vector
s = @(x)heaviside(x+1).*heaviside(-x)+heaviside(x).*heaviside(1-x); % Step
function between -1 and 1
phi = @(x) exp(-1./(1-x.^2)).*s(x); % Test function
d = @(t) integral(@(x)phi(x),0,t); % Data
fplot(d,[0,1])
However, none of the MATLAB tutorials seem to be useful in plotting a fast Fourier transform of d, which is defined in terms of a variable integral.
If I try with
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
s = @(x)heaviside(x+1).*heaviside(-x)+heaviside(x).*heaviside(1-x); % Step
function
phi = @(x) exp(-1./(1-x.^2)).*s(x); % Test function
d = @(t) integral(@(x)phi(x),0,t); %Data
plot(1000*t(1:50),d(1:50))
Then I get the following error:
Error using integral
A and B must be floating-point scalars.
Error in @(t)integral(@(x)phi(x),0,t)
I don't know how to fix this though.