高斯函数的sigma变量选择

时间:2017-01-08 10:29:10

标签: filtering fft

我是信号处理的新手,想要使用fft应用低通滤波器。 我发现this post回答了我的问题。在使用它时,我有一个问题: 鉴于我的截止频率为3500Hz,采样率为25600Hz, 生成高斯曲线时sigma的值是多少,由下面的eigenchris'answer代码给出?

gauss = zeros(size(Y));    
sigma = 8;                           % just a guess for a range of 20

gauss(1:r+1) = exp(-(1:r+1).^ 2 / (2 * sigma ^ 2));  % +ve frequencies
gauss(end-r+1:end) = fliplr(gauss(2:r+1));           % -ve frequencies
y_gauss = ifft(Y.*gauss,1024);

以下是我正在使用的功能代码:

clf; clc;
Fs    = 25600;
file   = '01cKhaitan181015M4_Opp_LeftS1H8_a.dat';
signal = dlmread(file); % read file from specified location
signal = signal - mean(signal);

N      = size(signal, 1);
time   = 1000*(0 : N-1)/Fs;    % in msec
freq   = (-Fs/2 : Fs/N : Fs/2-Fs/N)';

Y = fft(signal, 1024);

r = 141; % range of frequencies we want to preserve

gauss = zeros(size(Y));
sigma = 119.75; 
gauss(1:r+1) = exp(-(1:r+1).^ 2 / (2 * sigma ^ 2));  % +ve frequencies
gauss(end-r+1:end) = fliplr(gauss(2:r+1));           % -ve frequencies
y_gauss = ifft(Y.*gauss,1024);

hold on;
plot(time, signal, 'k'); plot(time, abs(y_gauss), 'c');
legend('signal', 'gaussian', 'Location', 'southwest')
hold off;

以下是数据文件的链接

https://www.dropbox.com/s/edb8g43j4a54jvq/01cKhaitan181015M4_Opp_LeftS1H8_a.dat?dl=0

1 个答案:

答案 0 :(得分:0)

截止频率定义为衰减为0.5或~6dB的频率。您已经知道所需的截止频率为3500Hz。下一步是获取相应的索引:

cutoff_frequency = 3500;
sampling_rate = 25600;
cutoff_index = 1 + cutoff_frequency/sampling_rate * length(Y);

在那个cutoff_index,您希望获得所需的0.5衰减。求解sigma,在高斯公式cutoff_index处产生0.5的衰减:

%% Derivation of sigma value
% 0.5 = exp(-cutoff_index^2 / (2 * sigma ^ 2));
% log(0.5) = -cutoff_index^2 / (2 * sigma ^ 2));
% sigma^2 = -cutoff_index^2 / (2 * log(0.5));
% sigma^2 = cutoff_index^2 / (2 * log(2));

得到以下特性:

sigma = cutoff_index / sqrt(2 * log(2));

因此,如果例如length(Y)为1024,则会得到

sigma = (3500/25600 * 1024) / sqrt(2 * log(2)); % approx. 119.75