Facebook
From gg, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 139
  1. clc;  clear;  hold on;
  2. axis([-100,100,-100,100]);
  3. plot(-100:100,0,'r.');
  4. plot(0,-100:100,'r.');
  5. x1=input('X1= ');
  6. y1=input('Y1= ');
  7. x2=input('X2= ');
  8. y2=input('Y2= ');
  9. dx=x2-x1;
  10. dy=y2-y1;
  11. if abs(dy)>abs(dx)
  12.     length=abs(dy);
  13. else
  14.  length=abs(dx);
  15. end
  16. xinc=dx/length;
  17. yinc= dy/length;
  18. x=x1:xinc:x2;
  19. y=y1:yinc:y2;
  20. round(x)
  21. round(y)
  22. plot(x,y,'b.');
  23. disp('X=')
  24. disp(x')
  25. disp('Y=')
  26. disp(y')
  27.