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!