Advertisement
makispaiktis

PROS_Exercises1_sim

Mar 2nd, 2021 (edited)
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.47 KB | None | 0 0
  1. % Παραμετροι
  2. m = 1;
  3. k = 100;
  4. b = 2;
  5.  
  6. % Function Handle
  7. u = @(t) sin(t);
  8.  
  9. % Initial State
  10. x0(1) = 0;
  11. x0(2) = 1;
  12. tspan = [0 10];
  13.  
  14. % Simulation
  15. [t, state] = ode15s(@(t, state)PROS_Exercises1_msd(t, state, m, b, k, u), tspan, x0);
  16.  
  17. % Plot
  18. figure(1);
  19. plot(t, state(:, 1));                % Θεση
  20. figure(2);
  21. plot(t, state(:, 2));                % Ταχυτητα
  22. % Φυσικο πορτρετο - Τροχια
  23. figure(3);
  24. plot(state(:, 1), state(:, 2));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement