title: Gaussian wave generation with a given central frequency
body: <p>The formula for gaussian wave is
  1/[sqrt(2* pi* variance)]*exp{-[(x-xo).^2/(2*variance)]};</p>
  
  <p>I have this question in 3 parts:</p>
  
  <p>1) How to generate a time domain Gaussian signal with a given central frequency. </p>
  
  <p>(I tried to control it by changing the "variance" value but it is a trial and error method. Is there any other simple way to achieve it.)</p>
  
  <p>2) My second problem is in determining its frequency spectrum. </p>
  
  <p>(I generate a Gaussian signal in time domain and took its fourier transform using FFT. Problem is that all frequencies are distributed around the zero hertz rather than being around the central frequency.)</p>
  
  <pre><code>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % test for gausssian signal ; Time to Freq
  % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  dt=.0001;
  fs=1/dt; %sampling frequency
  fn=fs/2;
  n=1000;
  t=dt*(-n/2:n/2); %time base
  
  sigma=0.001;     variance=sigma^2;
  
  xt=1/(sqrt(2*pi*variance))*(exp(-t.^2/(2*variance)));
  subplot(2,1,1); plot(t,xt,'b'); 
  title(['Gaussian Pulse \sigma=', num2str(sigma),'s']);
  xlabel('Time(s)'); ylabel('Amplitude');
  
  xf = fftshift(fft(xt));
  f = fs*(-n/2:n/2)/(n/2); %Frequency Vector
  subplot(2,1,2); plot(f,xf.*conj(xf),'r'); title('Magnitude of FFT');      
  xlabel('Frequency (Hz)'); ylabel('Magnitude |X(f)|');
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/k8x3i.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k8x3i.jpg" alt="enter image description here"></a></p>
  
  <p>3) As a reverse exercise, I defined the frequency spectrum around a given frequency and then estimated the amplitude spectrum. I varied the central frequency f0 and found the width of the pulse doesn't change. Where as in principle the width should have changed if higher frequencies are contributing.</p>
  
  <pre><code>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % test for gausssian signal ; Freq --&gt; Time --&gt; Freq
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  clc;  clear all;
  
  dt=0.001;
  fs=1/dt; %sampling frequency
  fn=fs/2;
  n=200;  % provide a even no
  
  f=1/dt*(-n/2+1:n/2-1)/(n/2); %time base
  
  f0=800 ;  % properties of source: position
  sigma=20;     % properties of source: width
  variance = sigma^2;
  
  xf=1/(sqrt(2*pi*variance))*(exp(-((f-f0).^2/(2*variance))));
  figure(1); subplot(3,1,1); plot(f,xf,'b'); 
  title(['Gaussian Pulse \sigma=', num2str(sigma),'s']);
  xlabel('Freq');   ylabel('Amplitude');
  
  xt=fftshift(ifft(xf));
  t=1/fs*(-n/2+1:n/2-1)/(n/2);
  subplot(3,1,2); plot(t,xt.*conj(xt),'b'); 
  xlabel('Time(s)');   ylabel('Amplitude');
  
  xtf=(fft((fftshift(xt))));
  subplot(3,1,3); plot(f,xtf.*conj(xtf),'b'); 
  xlabel('Freq');   ylabel('Amplitude')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RCtlh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RCtlh.jpg" alt="enter image description here"></a></p>