MATLAB: F=@(t,y) 4*exp(0.8*t)-0.5*y; tspan = [0 4]; y0 = 2; h = 1; [t,y] = ode_euler(f,tspan,y0,h)

coding

f=@(t,y) 4*exp(0.8*t)-0.5*y;
tspan = [0 4];
y0 = 2;
h = 1;
[t,y] = ode_euler(f,tspan,y0,h)
why this code is not working

Best Answer

tspan = [0 4];
y0 = 2;
[t1,y1] = ode45(@(t,y) 4*exp(0.8*t)-0.5*y,tspan,y0,h);
figure('name','Reda','color','w');
plot(t1,y1, 'r-','LineWidth',2);grid on;
xlabel('Time');ylabel('Solution y(Time)');
title('And you instead of a blanket substitute solver Euler');
Related Question