View Code
1 %% 2 clc; 3 clear; 4 %% 5 %半径 6 R=2; 7 %生成数据个数 8 n=1000; 9 %% 10 a=2*pi*rand(1,n); 11 12 rx1=R*rand(1,n); 13 x1=sin(a).*rx1;y1=cos(a).*rx1; 14 15 rx2=R*rand(1,n)+R+1; 16 x2=sin(a).*rx2;y2=cos(a).*rx2; 17 18 rx3=R*rand(1,n)+2*R+1+1; 19 x3=sin(a).*rx3;y3=cos(a).*rx3; 20 21 c=0:2*pi/100:2*pi; 22 plot(R*sin(c),R*cos(c),'-b',x1,y1,'r.',x2,y2,'o',x3,y3,'g*') 23 legend('线','类型一','类型二','类型三','-b','r.','o','g*')