# Matlab Code Help - Gaussian Function

--------------------------------------------------------------------------------

Hello,

I am new to this forum so please kindly let me know if my question needs to be posted in another area.
I am trying to write a matlab code to show a chirped Gaussian function and I am having some trouble with it. I am trying to obtain a chirped Gaussian pulse by modulating a chirped sinusoid by a Gaussian envelope. The modulation frequency is 50GHz.

When I implement the Gaussian code, I don't believe I am getting the right results.

Any help that can be rendered is much appreciated.

My code is below:

c = 3e8*1e-12; % (m/ps; set time unit to ps)

N = 2^16; % Number of time points
tmin = 0; % time aperture (window) start time
tmax = 1e3; % time aperture stop time (ps);
t0 = (tmax-tmin)/2; % center the pulse in the time window (ps)
dt = (tmax - tmin)/(N-1); % time step
t = (tmin:dt:tmax)'; % Time scale

lambda = 1550e-9; % Wavelength of launched pulse (m)
bandwidth = 20e-9; % starting bandwidth (nm)
P0 = 100; % peak power (W)
A = sqrt(P0); % A is the amplitude of the wave to be propagated

T0 = 0.44*lambda^2/(c*bandwidth); % FWHM of Guassian

chirp = -1;
w = 2*pi*50e9;
cp = A*exp(i*w*t).*exp((-(t-t0).^2/2*T0^2)*(1-i*chirp*T0^2)) % Chirped Gaussian function
cpf = fft(cp);

figure;
plot(t(N/2-400:N/2+400), abs(cp(N/2-400:N/2+400)), 'linewidth', 2); %time domain plot
figure;

plot(f, (cpf), 'linewidth', 2); %frequency domain plot

Thank you