您可以将极坐标图“展开”成笛卡尔图,以更好地了解这里发生的情况。如下所示,在给定输入的情况下,在 x-y 空间中用pchip 外推到0 和360 度数是非常合理的。
如果您想指定端点之间的行为,那么您需要在输入数据中添加人工端点,从而强制插值是循环的。
即
% 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