我可以使用pol2cart创建一个情节,但是如何才能让角度显示在最后一行?请参阅以下代码:
hold on ;
for angle = 0:20:(360-20)
[x1,y1] = pol2cart( angle / 180 * pi , [0 2]);
plot(x1,y1,'r')
end
for rho = 0:0.1:2
[x1,y1] = pol2cart( 0:0.01:2*pi , rho);
plot(x1,y1,'b')
end
axis equal
我试图让角度增量显示在周围,见下图。 请注意我没有画出所有编号的角度,只是为了表明我想要做的事情
PS:我使用octave 3.8.1尝试使用与matlab相同的语言语法
答案 0 :(得分:1)
您可以执行类似
的操作step = 20;
r= 2.2;
for idx = 0:step:360-step
text(r*cos(pi*idx/180),r*sin(pi*idx/180),num2str(idx), ...
'HorizontalAlignment','center', 'color',[1 .5 0])
end
为了更好地适应,请包括
axis(1.05*[-r r -r r])
axis equal
(这适用于MATLAB,我不知道Octave中的语法是否完全相同。)
答案 1 :(得分:0)
这是动画的信息和情节
%polar_chart_with_angles and there opposites
clear all, clc, clf
%find how many angles to make one full cycleremeber to divide by two if using stereo signal 180 out of phase
incr=72;
angle_wanted=incr;
n = lcm(360, 180 - angle_wanted) / (180 - angle_wanted)
angle_div=[0:incr:incr*n] %angle divsions
angle_div_mod=mod(angle_div,360) %angle divsions mod into 360
angle_div_mod_opp=mod(angle_div+180,360) %oppsite angle divsions mod into 360
%for circles
r= 2.2;
for rho = 0:0.1:2
[x1,y1] = pol2cart( 0:0.01:2*pi , rho);
plot(x1,y1,'b')
axis(1.10*[-r r -r r])
axis equal
hold on;
end
%for orig angles
for ii=1:n
angle=angle_div(ii)
[x1,y1] = pol2cart( angle / 180 * pi , [0 2]);
plot(x1,y1,'r')
hold on;
title_h=title(['Norig= ', int2str(ii)]);
%title_h = title('This is the title');
set(title_h, 'Position', [0.5, 0.02],'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'left')
%%for creating orig angles
idx=angle_div_mod(ii);
text(r*cos(pi*idx/180),r*sin(pi*idx/180),num2str(idx), 'HorizontalAlignment','center', 'color',[1 .5 0])
pause (.1)
end
%for oppsite angles
for ii=1:n
angle_opp=angle_div_mod_opp(ii)
[x1,y1] = pol2cart( angle_opp/ 180 * pi , [0 2]);
plot(x1,y1,'g')
hold on;
title(['Nopp= ', int2str(ii)]);
%for creating oppsite angles
idx=angle_div_mod_opp(ii);
text(r*cos(pi*idx/180),r*sin(pi*idx/180),num2str(idx), 'HorizontalAlignment','center', 'color',[.5 .7 .7])
pause (.1)
end