Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. clc;
  2. global u mu;
  3.  
  4. u = input('Budiaci signal (u): ');
  5. mu = input('Parameter mu: ');
  6. T = input('Pociatocny a koncovy cas [t0 t1]: ');
  7. PP = input('Pociatocne podmienky [* *]: ');
  8.  
  9. fprintf('(1) Fázový portrét pre NDS \n');
  10. fprintf('(2) Fázový portrét pre 1X_s \n');
  11. fprintf('(3) Casovy priebeh pre NDS \n');
  12. fprintf('(4) Casovy priebeh pre 1X_s \n');
  13. fprintf('(5) pre koniec \n');
  14. in = input('Zadajte graf pre vykreslenie: ');
  15.  
  16. p = [1 -mu 1];
  17. roots_ = roots(p);
  18. while in ~= 5
  19. if(in == 1)
  20. figure('Name','Van der Polov oscilátor - Fázový portrét pre NDS');
  21. fp('vdp_nelin',T);
  22. [x1, x2] = meshgrid(-10:0.5:10, -10:0.5:10);
  23. x1der = x1;
  24. x2der = mu * (1 - x1^2) * x2 - x1 + u;
  25. quiver(x1, x2, x1der, x2der, 'k', 'LineWidth', 1.5)
  26. title('Van der Polov oscilátor - Nelinearny System', 'FontSize', 25);
  27. lines();
  28. elseif(in == 2)
  29. figure('Name','Van der Polov oscilátor - Fázový portrét pre 1X_s');
  30. fp('vdp_lin',T);
  31. [x1, x2] = meshgrid(-10:0.5:10, -10:0.5:10);
  32. x1der = x1;
  33. x2der = mu * (1 - x1^2) * x2 - x1 + u;
  34. quiver(x1, x2, x1der, x2der, 'k', 'LineWidth', 1.5)
  35. makeTitle(roots_(1,1),roots_(2,1));
  36. lines();
  37. elseif(in==3)
  38. figure('Name','Van der Polov oscilátor - casovy priebeh');
  39. [t,x]=ode45('vdp_nelin', T, [1 0]);
  40. [t_rk,x_rk]=runge_kutta(@vdp_nelin, T, [1 0]);
  41. makeSubPlot(t, x, t_rk, x_rk);
  42. elseif(in==4)
  43. figure('Name','Van der Polov oscilátor - casovy priebeh pre 1xs');
  44. [t,x]=ode45('vdp_lin', T, [1 0]);
  45. [t_rk,x_rk]=runge_kutta(@vdp_lin, T, [1 0]);
  46. makeSubPlot(t, x, t_rk, x_rk);
  47. else
  48. fprintf('Wrong input');
  49. end
  50.  
  51. clc;
  52. fprintf('(1) Fázový portrét pre NDS \n');
  53. fprintf('(2) Fázový portrét pre 1X_s \n');
  54. fprintf('(3) Casovy priebeh pre NDS \n');
  55. fprintf('(4) Casovy priebeh pre 1X_s \n');
  56. fprintf('(5) pre koniec \n');
  57. in = input('Zadajte graf pre vykreslenie: ');
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement