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)

1 次查看(过去 30 天)
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

采纳的回答

Pavel Osipov
Pavel Osipov 2019-10-5
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by