ode45 错误,索引越界,因为 numel(x)=1
ode45 error, index out of bounds because numel(x)=1
function xx = test(x, t)
xx(1) = x(2);
xx(2) = x(3) * cos(x(4) + x(1));
xx(3) = 0;
xx(4) = 0;
end
那是我的脚本,我很困惑为什么会收到此错误。
ODE suites 的右侧将参数作为 (t,x)
传递,其中 t
始终是标量。
所以你的函数签名应该是
function xx = test(t,x)
function xx = test(x, t)
xx(1) = x(2);
xx(2) = x(3) * cos(x(4) + x(1));
xx(3) = 0;
xx(4) = 0;
end
那是我的脚本,我很困惑为什么会收到此错误。
ODE suites 的右侧将参数作为 (t,x)
传递,其中 t
始终是标量。
所以你的函数签名应该是
function xx = test(t,x)