Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. %steven pitman
  2.  
  3. %clear screen and memory
  4. clear, clc
  5.  
  6. %define the function
  7. yprime = @(x,y) -(3*x.^2).*y;
  8.  
  9. %define solution curves
  10. f1 =@(x) 2*exp(-x.^3);
  11. f2 =@(x) 1*exp(-x.^3);
  12. f3 =@(x) 1*exp(-x.^3);
  13. f4 =@(x) 3*exp(-x.^3);
  14. f5 =@(x) 4*exp(-x.^3);
  15.  
  16. %define points to determine slope
  17. xx = [0:.2:3]';
  18. yy = [0:.2:3];
  19.  
  20.  
  21. %x and y components of the slope vectors
  22. dy = yprime(xx,yy);
  23. dx = ones(size(dy));
  24.  
  25. %vector to normalize slope
  26. L=sqrt(1+dy.^2);
  27.  
  28. %plot the slope field and solution curves
  29. figure();
  30. hold on
  31. quiver(xx,yy,dx./L,dy./L)
  32. xlim([0,3])
  33. ylim([0,3])
  34.  
  35. fplot(f1,[0,3],'LineWidth',2);
  36. fplot(f2,[0,3],'LineWidth',2);
  37. fplot(f3,[0,3],'LineWidth',2);
  38. fplot(f4,[0,3],'LineWidth',2);
  39. fplot(f5,[0,3],'r','LineWidth',2);
  40.  
  41. hold off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement