MATLAB,如何在圆上画正弦sin?

2025-12-25 02:17:42
推荐回答(1个)
回答1:

r0 = 100; r1 = 80; r2 = 130;

st = 0.01;

t = 2*(0:st:pi);

x0 = r0*cos(t); 

y0 = r0*sin(t);

xx = linspace(0,pi,length(t)/2);

rr = r0+(r2-r0)*sin(xx);

xx1 = rr.*cos(xx); 

yy1 = rr.*sin(xx);

xx = linspace(pi,2*pi,length(t)/2);

rr = r0+(r0-r1)*sin(xx);

xx2 = rr.*cos(xx); 

yy2 = rr.*sin(xx);

xx = [xx1 xx2]; 

yy = [yy1 yy2];

plot(x0,y0,'b:');

axis square

hold on

plot(r1*cos(t),r1*sin(t),'k:');

plot(r2*cos(t),r2*sin(t),'g:');

plot(xx,yy,'r-');

hold off