您可以将极坐标图“展开”为笛卡尔图,以更好地了解此处发生的情况。如下所示,在给定输入的情况下,在 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] 删除。
我来说两句