% Gaussian time-frequency scaling
% Carlos J. Cela, April 2012

clear all
close all

% Input parameters ********************
% *************************************

f  = 100e6;  % Enter here the central frequency
bw = 100e6;  % Enter here the bandwidth

% End of input parameters *************
% *************************************


% DO NOT MODIFY FROM HERE DOWN

% Calculate Gaussian parameters
pulsewidth = 1/bw;
t0 = 4*spread;

% Display time domain expression
disp(['exp(-0.5*((t-' num2str(t0) ')/' num2str(spread) ').^2);']);

% Plot pulse in time domain
dt = t0/500; % Something reasonable for plotting
t = 0:step:10*t0;
pulse=exp(-0.5*((t-t0)/pulsewidth).^2).*sin(2*pi*f*t);
plot(t,pulse);
grid on
title('Gaussian pulse, time domain');
xlabel('Time [s]');
ylabel('Magnitude');

% Calculate FFT
fezr=fft(pulse);
df=1/step;
npoint=length(pulse);
fr=df*(0:npoint/2)/npoint;
result=fezr(1:npoint/2+1);

% Select frequency range up to 100MHz
for fcut = 1:length(fr)
  if fr(fcut)>bw+f
    break;
  end
end

% Plot frequency domain
figure();
plot(fr(1:fcut),abs(result(1:fcut)));
grid on
title('Gaussian pulse, frequency domain');
xlabel('Frequency (Hz)');
ylabel('Magnitude');



