she*_*hea 6 time matlab trigonometry curve-fitting distortion
我想知道在Matlab中使用扭曲的时基来拟合正弦波的最佳方法.
时间失真由形式的n阶多项式(n~10)给出t_distort = P(t).
例如,考虑失真t_distort = 8 + 12t + 6t^2 + t^3(这只是幂级数的扩展(t-2)^3).
这会扭曲正弦波,如下所示:
IMG http://i59.tinypic.com/67ukcy.png
我想能够找到这种扭曲的正弦波的失真.(即我想找到这个功能t = G(t_distort),但是t_distort = P(t)未知.)
这是一个分析驱动的路线,它通过适当的角度展开来获取asin信号。然后,您可以使用角度或使用其他拟合方法来拟合多项式(搜索并查看)。最后,对拟合函数取正弦值,并将信号与拟合函数进行比较……请参阅以下教学示例:polyfitfit
% generate data
t=linspace(0,10,1e2);
x=0.02*(t+2).^3;
y=sin(x);
% take asin^2 to obtain points of "discontinuity" where then asin hits +-1
da=(asin(y).^2);
[val locs]=findpeaks(da); % this can be done in many other ways too...
% construct the asin according to the proper phase unwrapping
an=NaN(size(y));
an(1:locs(1)-1)=asin(y(1:locs(1)-1));
for n=2:numel(locs)
an(locs(n-1)+1:locs(n)-1)=(n-1)*pi+(-1)^(n-1)*asin(y(locs(n-1)+1:locs(n)-1));
end
an(locs(n)+1:end)=n*pi+(-1)^(n)*asin(y(locs(n)+1:end));
r=~isnan(an);
p=polyfit(t(r),an(r),3);
figure;
subplot(2,1,1); plot(t,y,'.',t,sin(polyval(p,t)),'r-');
subplot(2,1,2); plot(t,x,'.',t,(polyval(p,t)),'r-');
title(['mean error ' num2str(mean(abs(x-polyval(p,t))))]);
Run Code Online (Sandbox Code Playgroud)

p =
0.0200 0.1200 0.2400 0.1600
Run Code Online (Sandbox Code Playgroud)
NaN我预先分配并避免采用不连续点 (locs)的原因asin是为了减少以后拟合的误差。正如您所看到的,对于 0,10 之间的 100 个点,平均误差约为浮点精度,并且多项式系数尽可能精确。
事实上,您没有采用导数(如在非常优雅的希尔伯特变换中),因此可以在数值上精确。对于相同的条件,希尔伯特变换解将具有更大的平均误差(单位阶 vs 1e-15)。
这种方法的唯一限制是,在 asin 翻转方向的区域中需要足够的点,并且 内部的函数sin表现良好。如果存在采样问题,您可以截断数据并仅维持接近于零的较小范围,这样就足以表征sin. 毕竟,您不需要数百万个操作点来适应 3 参数函数。