具有给定中心频率的高斯波生成

时间:2016-02-04 21:20:25

标签: matlab signal-processing fft gaussian ifft

高斯波的公式是 1 / [sqrt(2 * pi * variance)] * exp { - [(x-xo)。^ 2 /(2 * variance)]};

我有三个部分提出这个问题:

1)如何生成具有给定中心频率的时域高斯信号。

(我试图通过改变“方差”值来控制它,但它是一种试错法。还有其他简单的方法来实现它。)

2)我的第二个问题是确定其频谱。

(我在时域中生成高斯信号,并使用FFT进行傅立叶变换。问题是所有频率都是在零赫兹附近分布而不是在中心频率附近。)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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)作为反向练习,我定义了给定频率附近的频谱,然后估算了幅度谱。我改变了中心频率f0,发现脉冲宽度没有变化。原则上,如果更高的频率有贡献,宽度应该已经改变。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 个答案:

答案 0 :(得分:0)

正如我在post中指出的那样,要将高斯脉冲调制到更高的频率(并保持信号实值),你需要将信号乘以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)|');

哪个应该给你一个类似的结果:

Modulated Gaussian pulse plot