ODE45 returns NaN

10 次查看(过去 30 天)
Raquel Andrade
Raquel Andrade 2022-5-24
I wrote this code to plot the solution of an EDO, but MATLAB just returns NaN values. I can't find my mistake, can anyone help me?
tspan = [0 100];
v0 = 0;
[t,v] = ode45(@(t,v)(4800./(2200.*(1-0.8.^(t./40)))- 9.81),tspan,v0)
figure(1)
plot(t,v,'-o')
xlabel('Time (s)')
ylabel('Speed (m/s)')

回答(1 个)

Alan Stevens
Alan Stevens 2022-5-24
t = 0 causes a problem. Try tspan = [0.1 100]; for example.

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by