Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. x = -1 : 0.01 : 1;
  2. y = 1./(25*(x.^2) + 1);
  3.  
  4. plot(x, y, 0, 1, 'r*');
  5.  
  6. [x, y] = meshgrid(-10:0.5:10, -10:0.5:10);
  7. z = @(a,b) a.^2+b.^2;
  8. subplot(2,1,1);
  9. surf(x, y, z(x, y));
  10. hold on
  11. colormap(hot);
  12. plot3(0,0,z(0,0), 'g*', 'MarkerSize', 100);
  13. subplot(2,1,2);
  14. [C, h] = contour(x,y,z(x,y));
  15. %axis('square');
  16. dx = [-5, -2, -2, 0];
  17. dy = [-3, -3, 0, 0];
  18. hold on;
  19. plot(dx(1), dy(1), 'r*');
  20. text(dx(1), dy(1), 'START');
  21. hold on;
  22. plot(dx(4), dy(4), 'g*');
  23. text(dx(4), dy(4), 'STOP');
  24. hold on;
  25. plot(dx(2:end-1), dy(2:end-1), 'go');
  26. hold on;
  27. for i = 1 : 3
  28. line([dx(i), dx(i+1)], [dy(i) , dy(i+1)]);
  29. end
  30.  
  31. clabel(C, h);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement