% function output = bs_lorenz_rhs(t,x) % Compute right hand side (rhs) term of the Lorenz System % dX/dt = -aX +aY % dY/dt = +rX -Y -XZ % dZ/dt = -bZ +XY % function output = bs_lorenz_rhs(t,x) % model parameters a=10.; r=28.; b=8./3.; X=x(1); Y=x(2); Z=x(3); % compute right hand side of differential equation rhsX = - a*X + a*Y ; rhsY = + r*X - Y - X*Z ; rhsZ = - b*Z + X*Y ; % assign rhs to output variable output = zeros(3,1); output(1)=rhsX; output(2)=rhsY; output(3)=rhsZ; % Alternatively one could have done this to shorten the code. % output = [a*(x(2)-x(1)), x(1)*(r - x(3)) - x(2), x(1)*x(2) - b*x(3)]';