我无法将数组s0中的值插入前一个脚本(myLorenz)中的三个等式中。假设新的s0值插入方程中的S(1),S(2)和S(3)点。但是我收到一条错误消息说明
[T,X,Y,Z] = myLorenzSolver([0,50],[0; 1; 1.05],10,28,8 / 3);
“尝试访问S(2);索引越界,因为numel(S)= 1。”
function [T,X, Y, Z] = myLorenzSolver(tSpan, s0, sigma, rho, beta)
t0 = tSpan(1);
tf = tSpan(end);
%integrations
[T, Y] =ode45(@myLorenz,[t0,tf],[sigma,rho,beta]);
end
function [dS] = myLorenz(t,S,sigma,rho,beta)
%dx/dt
dx = sigma*(S(2)-S(1));
%dy/dt
dy = S(1)*(rho-(S(3)))-S(2);
%dz/dt
dz =(S(1)*S(2))-(beta*S(3)) ;
dS = [dx,dy,dz]';
end
提前感谢您的帮助!