[英]1D gaussian filter over non equidistant data
I have a data distributed in non-equidistant 1D space and I need to convolve this with a Gaussian filter, 我有一个分布在非等距1D空间的数据,我需要用高斯滤波器对其进行卷积,
gaussFilter = sqrt(6.0/pi*delta**2)*exp(-6.0*x**2 /delta**2);
where delta
is a constant and x
corresponds to space. 其中
delta
是常数, x
对应于空间。
Can anyone hint how to perform a good integration (2nd order) as the data is not equally spaced taking care of the finite end? 任何人都可以暗示如何执行良好的集成(第二顺序),因为数据不是等间隔处理有限结束? I intend to write the code in Fortran, but a Matlab example is also welcome.
我打算在Fortran中编写代码,但也欢迎使用Matlab示例。
use this: 用这个:
function yy = smooth1D(x,y,delta)
n = length(y);
yy = zeros(n,1);
for i=1:n;
ker = sqrt(6.0/pi*delta^2)*exp(-6.0*(x-x(i)).^2 /delta^2);
%the gaussian should be normalized (don't forget dx), but if you don't want to lose (signal) energy, uncomment the next line
%ker = ker/sum(ker);
yy(i) = y'*ker;
end
end
Found something which works. 找到有用的东西。 Though not sure if this is very accurate way as the integration (trapz) is of first order.
虽然不确定这是否非常准确,因为集成(trapz)是第一顺序。
function [fbar] = gaussf(f,x,delta )
n = length(f);
fbar = zeros(n,1);
for i=1:n;
kernel = sqrt(6/(pi*delta^2))*exp(-6*((x - x(k))/delta).^2);
kernel = kernel/trapz(x,kernel);
fbar(i) = trapz(x,f.*kernel);
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.