2
我想繪製幾個同心圓幾點就像這樣:如何依次繪製幾個同心圓上的點?
在不同的圈子點的數量是相同的,待確定。半徑的差異是相同的。
但是我面臨的問題是,如果我想使用for
函數,我定義了i = 1:total number of points
。我不知道如何選擇正確的角度值。誰能幫我?
這裏是我寫的代碼:
R_steplength = 1; %difference of radius
angle_point = 20; %total number of points on one circle
max_R = 4; %outer radius of circle
central_x = 1; % origin of concentric circle
central_y = 1;
total_circle_points = (max_R/R_steplength) * angle_point; %calculate total
points
fin_x= zeros(1, total_circle_points); %define output points position
fin_y = zeros(1, total_circle_points);
for i = 1:total_circle_points
for j = 1:angle_point
if rem(i+1, 20)~= 1
k = floor(i/20);
angles = linspace(0,2*pi,angle_point);
fin_x(i) = R_steplength*(k+1)*cos(angles(j))+central_x;
fin_y(i)= R_steplength*(k+1)*sin(angles(j))+central_y;
else
fin_x(i) = central_x + R_steplength*(k+2);
fin_y(i) = central_y + R_steplength*(k+2);
end
plot(fin_x(:),fin_y(:),'ro')
end
end