# I want to plot a gaussian pulse in MATLAB in the frequency domain, with its centre at the highest value

I have tried one way but i am getting 2 peaks at the edges as shown in the picture. I have used 1 part of my code for the signal generation where i used the gauspuls command (reference: www.simsonic.fr) and for plotting the frequency spectrum, i picked up the code from a previous post.

The screenshot contains the relevant signals.the top for the frequency domain signal, bottom one is of the source signal.

%for signal generation

f0=0.5;
t0=1.5;
bndwdth=2;
duration=2*t0;

timebase=(0:round(duration/dt)-1)'*dt;
[signalI,signalQ]=gauspuls(timebase-t0,f0,bndwdth);
signal=signalQ;
%signal=signal/max(signal);
signal=20*signal;

figure(2)
plot(timebase,signal,'.-')
title('source signal')
xlabel('time (µs)')

%for fft:
midf=5e5;
figure(1)
L=1000;
fs=midf*10;
%NFFT = 2^nextpow2(L);
NFFT=2286;
Mb = fft(signal,NFFT)/L;
f = fs*linspace(0,1,NFFT); %Frequency Vector
plot(f,abs(Mb))
title('Gaussian Pulse in Frequency Domain in bone')
xlabel('Frequency (f)')
ylabel('|Magnitude(f)|')


• Hi and welcome to SE, as the quality of your screenshots is very bad, and the main body of your question is your code, I am not sure what exactly your problem is. Please edit your question and add the information what your goal is (desired output) ... – Irreducible Apr 8 at 10:57
• Also, look up fftshift in Matlab's documentation, and their explanation on how to plot a spectrum in doc fft. – MBaz Apr 8 at 13:33
• Yes, but @MBaz, i looked up the fftshift in MATLAB, it gives all the zero frequency content in the centre. @ irreducible i will take your feedback, correcting the same. – Kunal Khosla Apr 8 at 16:07
• @KunalKhosla Edit your question to explain what you expect to obtain, and how that is different from what you're obtaining. – MBaz Apr 8 at 16:12
• I expected a peak at the maximum amplitude at the centre frequency ie. 500Khz but i am getting the peaks at 0 and 1Mhz. – Kunal Khosla Apr 8 at 16:27