我想通过非整数移位来移位向量,线性插值似乎不是很准确,所以我尝试使用sinc通过以下使用傅立叶变换的代码进行插值。
function y = fshift(x,s)
% FSHIFT Fractional circular shift
% Syntax:
%
% >> y = fshift(x,s)
%
% FSHIFT circularly shifts the elements of vector x by a (possibly
% non-integer) number of elements s. FSHIFT works by applying a linear
% phase in the spectrum domain and is equivalent to CIRCSHIFT for integer
% values of argument s (to machine precision).
needtr = 0; if size(x,1) == 1; x = x(:); needtr = 1; end;
N = size(x,1);
r = floor(N/2)+1; f = ((1:N)-r)/(N/2);
p = exp(-j*s*pi*f)';
y = ifft(fft(x).*ifftshift(p)); if isreal(x); y = real(y); end;
if needtr; y = y.'; end;
当我将方波移位整数移位时,代码中没有问题,但当移位为非整数时,输出会出现显着波动
IE。,
s=[zeros(1,20) ones(1,20) zeros(1,20)];
b=fshift(s,3.5);
stem(b)
如何克服这个问题,还有其他准确的方法吗?
尝试这个:
假设您要移动 3.5。找出过采样值是多少(即哪个值会将移位更改为整数 - 在本例中为 2)。
ov = 2;
a = 3.5*ov;
y = downsample(circshift(interp(s,2).', -a),ov);
这在边缘仍然有一些振铃,但比您的 sinc 方法少得多。我不确定这是否是由于吉布斯现象造成的,因为正如评论中提到的,您本质上是截断或泄漏。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)