أخر الاخبار

program for drawing a circle

  drawing a circle

ex/The matlab program for drawing a circle using parametric polar method.

sol//

function circle(xc,yc,r);

 clf; 

dt=1/r; 

th=[0:dt:2*pi]; 

x=xc+r*cos(th);

 y=yc+r*sin(th);

 plot(x,y,'k');

 axis([0 100 0 100]); 

axis square; 


ex/- The matlab program for drawing a circle using eight-way symmetry method.

sol//

function symmetrycircle(xc,yc,r); 

clf; 

dt=1/r; 

th=[0:dt:pi/4]; 

x=r*cos(th);

 y=r*sin(th); 

plot((xc+x),(yc+y),':k'); 

hold on

 plot((xc+x),(yc-y),'k');

 plot(xc-x,yc+y,'k');

 plot(xc-x,yc-y,':k');

 plot(xc+y,yc+x,'k');

 plot(xc-y,yc+x,':k');

 plot(xc+y,yc-x,':k');

 plot(xc-y,yc-x,'k'); 

axis([0 100 0 100]);

 axis square; 


ex/The matlab program for drawing an arc start from pi to pi*2.

sol//

function arc(xc,yc,r,sa,ea);

 clf; 

dt=1/r; 

th=[sa:dt:ea];

 x=xc+r*cos(th);

 y=yc+r*sin(th);

 plot(x,y,':r'); 

axis([0 100 0 100]); 

axis square;



ex/The matlab program for drawing an ellipse using polar method.

sol//

function ellipse(xc,yc,xr,yr);

 clf; 

dt=1/((xr+yr)/2); 

th=[0:dt:2*pi];

 x=xc+xr*cos(th); 

y=yc+yr*sin(th); 

plot(x,y,'k'); 

axis([0 100 0 100]);

 axis square ;



ex/write a matlab programs to draw the following figures.


sol//

function circle(xc,yc,r)

 plot(xc,yc,'+'); 

dt=1/r; 

th=0:dt:2*pi;

 x=xc+r*cos(th);

 y=yc+r*sin(th); 

plot(x,y,'k'); 

axis([0 100 0 100]); 

axis square; 

-------------

function ellipse(xc,yc,xr,yr) 

dt=1/((xr+yr)/2); 

th=0:dt:2*pi;

 x=xc+xr*cos(th); 

y=yc+yr*sin(th); 

plot(x,y,'k'); 

axis([0 100 0 100]); 

axis square;

-------------

1-

hold on 

circle(50,50,75); 

circle(50,-25,30); 

circle(-25,50,30); 

circle(125,50,30); 

circle(50,125,30);

2-

hold on 

circle(60,40,20); 

circle(50,60,20); 

circle(70,60,20);

3-

hold on

 circle(40,60,30); 

circle(40,40,30);

4-

hold on 

ellipse(50,55,35,20); 

circle(50,55,5); 

circle(50,55,15);


تعليقات



حجم الخط
+
16
-
تباعد السطور
+
2
-