ODE_4thOrder.m 278 B

1234567891011121314
  1. clear; clc; close all;
  2. ode_system = @(t, Y) [
  3. Y(2);
  4. Y(3);
  5. Y(4);
  6. cos(2*t) - Y(1) - (1-Y(1)^2)*Y(2) - (1+t)*Y(3) - 2*Y(4)
  7. ]
  8. t_span = [0 10];
  9. initial_conditions = [1 0 0 0];
  10. [t, Y] = ode45(ode_system, t_span, initial_conditions);
  11. y_sol = Y(:, 1);
  12. plot(t, y_sol);