【问题标题】:Preserving shape local convexity/concavity with Matlab interpolation用 Matlab 插值保持形状局部凸/凹
【发布时间】:2021-02-23 10:31:27
【问题描述】:

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

样条曲线

芯片

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

有什么方法可以限制算法,使其不显示这种人为的趋势?

提前感谢您的任何建议。

【问题讨论】:

  • edit你的问题包括minimal reproducible example,特别是输入数据以及如何生成你的两个例子...
  • 我假设这可能是由于缺乏周期性条件。您是否尝试将 330° 的数据点也添加为 -30°,并且类似地将 30° 的数据点添加为 390°?

标签: matlab interpolation spline


【解决方案1】:

您可以将极坐标图“展开”成笛卡尔图,以更好地了解这里发生的情况。如下所示,在给定输入的情况下,在 x-y 空间中用pchip 外推到0360 度数是非常合理的。

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

% 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-21
    • 2011-10-05
    • 2022-01-16
    • 2016-11-21
    • 2013-07-11
    • 2011-01-28
    • 2019-05-16
    • 1970-01-01
    相关资源
    最近更新 更多