调用下列函数
输入:角度和半径
function show(Angles, R)
if max(size(Angles))~=1 && max(size(R))==1 %如果输入多个角度,但是只输入一个半径,默认半径全部相同
R = ones(max(size(Angles)),1)*R;
end
for i = 1:max(size(Angles ,1), size(Angles,2))
polarscatter(Angles(i)/180*pi ,R(i), 250,i, 'filled') %角度转弧度,半径,图形大小,颜色,填充
hold on
% rlim([max(min(R)-2,0),max(R)+1]) %绘图区域的半径上下限
rlim([0,10])
% thetaticks(0:20:180) %显示角度精度
% 设置极坐标范围为0到180度
% ax = gca;
% ax.ThetaLim = [0 180]; %只想要显示0-180°
% legend %图标
end
hold off
end
polarscatter(Angles(i)/180*pi ,R(i), 250,i, 'filled')
中的250,表示显示点的大小,可调,filled 表示是实心的
效果如下
如果只想要显示0-180°,
添加如下语句
ax = gca;
ax.ThetaLim = [0 180]; %只想要显示0-180°
如果把原点显示为方块
polarscatter(Angles(i)/180*pi ,R(i), 250,i, 'filled','Marker', 's') %角度转弧度,半径,图形大小,颜色,填充
效果如下
验证数据:
49.7711000000000 2
45.3178000000000 2
47.5764000000000 3
51.9100000000000 3
45.3178000000000 4
49.7711000000000 4
128.461700000000 7