Amc 41
Amc 41
% Initial condition
y0 = 1;
y1=0.1;
y2=0.01;
% Time span
tspan = [0 50];
subplot(3,1,1)
plot(t, y, "b-", "LineWidth", 2);
xlabel("Time t");
ylabel("Solution y(t)");
title("Solution of dy/dt = 100y + cos(t) using ode45");
grid on;
subplot(3,1,2)
[t, y] = ode45(f, tspan, y1);
plot(t, y, "b-", "LineWidth", 2);
xlabel("Time t");
ylabel("Solution y(t)");
title("Solution of dy/dt = 100y + cos(t) using ode45");
grid on;
1
Published with MATLAB® R2024b