problem3_2ndorderODE.m 340 B

12345678910111213141516171819
  1. clear all; close all; clc;
  2. ode_system = @(t, Y) [
  3. Y(2);
  4. -3 - (t^2 + Y(1))*Y(1) - (3*t+2*Y(1))*Y(2)
  5. ];
  6. t_span = [0, 10];
  7. initial_conditions = [1; 0];
  8. [t, Y] = ode45(ode_system, t_span, initial_conditions);
  9. figure;
  10. hold on;
  11. grid on;
  12. plot(t, Y(:, 1));
  13. plot(t, Y(:, 2));
  14. legend("y(t)", "y'(t)");
  15. xlabel("t");
  16. ylabel("y(t) & y'(t)");