1
votes

The formula for gaussian wave is 1/[sqrt(2* pi* variance)]*exp{-[(x-xo).^2/(2*variance)]};

I have this question in 3 parts:

1) How to generate a time domain Gaussian signal with a given central frequency.

(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.)

2) My second problem is in determining its frequency spectrum.

(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.)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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)|');

enter image description here

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.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test for gausssian signal ; Freq --> Time --> 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')

enter image description here

1

1 Answers

0
votes

As I indicated in this post, to modulate the Gaussian pulse to a higher frequency (and keeping the signal real-valued) you have multiply the signal by cos(2*pi*t*f0):

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;

f0 = 1000;
xt=cos(2*pi*t*f0) .* (exp(-t.^2/(2*variance)))/sqrt(2*pi*variance);
subplot(2,1,1); plot(t,xt,'b'); 
title(['Gaussian Pulse \sigma=', num2str(sigma),'s']);
xlabel('Time(s)'); ylabel('Amplitude');
axis([-0.02 0.02]);

xf = fftshift(fft(xt));
f = fs*(-n/2:n/2)/n; %Frequency Vector
subplot(2,1,2); plot(f,abs(xf),'r'); title('Magnitude of FFT');      
xlabel('Frequency (Hz)'); ylabel('Magnitude |X(f)|');

Which should give you a result similar to:

Modulated Gaussian pulse plot