使用 Matlab 插值保留形状局部凸/凹

圭多

我正在尝试插入一组散点值(图中的星号)。迄今为止效果最好的算法是:

样条

在此处输入图片说明

芯片

在此处输入图片说明

然而,它们都未能保持 30° 和 360° 方向之间曲线的自然趋势。正确的近似值应该介于两者之间。很明显,这两种不同的行为取决于已知值之前的内插线的斜率。

有没有办法限制算法,使其不显示这种人为的趋势?

预先感谢您的任何建议。

沃尔菲

您可以将极坐标图“展开”为笛卡尔图,以更好地了解此处发生的情况。如下所示,在给定输入的情况下,在 xy 空间中外推到0和 的360度数pchip是非常合理的。

如果您想规定端点的行为,那么您需要向输入数据添加人工端点,从而强制插值循环。

% Input points
a = 30:30:330;
b = [0.6, 0.8, 0.7, 0.3, 0.3, 0.0, 0.3, 0.3, 0.7, 0.8, 0.6];
% Extend the inputs by wrapping f(330deg)=f(-30deg), f(390deg)=f(30deg)
a_ext = [-30, a, 390]; 
b_ext = [b(end), b, b(1)];
% convert to radians    
a = deg2rad(a);
a_ext = deg2rad(a_ext);

figure();
% Polar plot
subplot(2,1,1)
polarplot( a, b, '.', 'markersize', 20 )
hold on
ainterp = linspace(0,2*pi,100);
polarplot( ainterp, pchip(a,b,ainterp), 'linewidth', 1 )
polarplot( ainterp, pchip(a_ext,b_ext,ainterp), 'k', 'linewidth', 1 )
rlim( [-0.2, 1] )
legend( {'Input points','pchip','pchip extended'} )
% Cartesian plot
subplot(2,1,2)
plot( rad2deg(a), b, '.', 'markersize', 20 )
hold on
plot( rad2deg(ainterp), pchip(a,b,ainterp), 'linewidth', 1.5 )
plot( rad2deg(ainterp), pchip(a_ext,b_ext,ainterp), 'k', 'linewidth', 1.5 )
ylim( [-0.2, 1] ); xlim( [0, 360] ); grid on

地块

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章