I am trying to get 1D Fourier transform of Rectangular pulse. Everything else appears fine; the zero frequency components appears very high and seems like a discrete peak.
Plot of FFT (link to jpeg image): https://drive.google.com/file/d/0B0Ah9soYnrlIYmw0UTJRNGhrWFE/edit?usp=sharing
I would appreciate if someone can tell me what am I doing wrong.
My Matlab code:
function FFT_1D_Example()
Tau = 10e-3; %CEST duration in second
NoOfPtsOnPulse = 1000;
%Time scale for the pulse
t_Pulse = (0:1:NoOfPtsOnPulse-1)*(Tau/(NoOfPtsOnPulse-1)); % in sec
B1Max = 1; % in tesla; current value = 3 uT
%% Simulating the pulse shape
%Reactangular pulse
B1_Array_Rect = ones(1, length(t_Pulse))*B1Max;
B1_Array_Rect(1) = 0.0;
B1_Array_Rect(end) = 0.0;
y = B1_Array_Rect;
figure(1); plot(t_Pulse, y); title('Pulse shape'); xlabel('time (seconds)')
%% FFT
[Y, NFFT] = Return_1D_FFT(y);
% Shift zero-frequency component to center of spectrum
Y = fftshift(Y)
% Plot single-sided amplitude spectrum.
figure(2); plot(abs(Y))
title('Two-Sided Amplitude Spectrum of y(t)')
end
function [Y, NFFT] = Return_1D_FFT(y)
L = length(y);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT);
end