Infinite recursion in code to graph second order differential equations
显示 更早的评论
I am trying to implement the sample code from a section titled Pass Extra Parameters to ODE Function in an article on second order differential equations: https://www.mathworks.com/help/matlab/ref/ode45.html
When I try to execute the following code, I get an error message saying there is likely an infinite recursion in the program.
function dydt = odefcn(t,y,A,B)
A = 1;
B = 2;
tspan = [0 5];
y0 = [0 0.01];
[t,y] = ode45(@(t,y) odefcn(t,y,A,B), tspan, y0);
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = (A/B)*t.*y(1);
plot(t,y(:,1),'-o',t,y(:,2),'-.')
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!