1

Im having trouble plugging in values from array s0 into three equations from a previous script(myLorenz). The new s0 values are suppose to be plugged into the S(1), S(2), and S(3) spots in the equations. However Im getting an error message stating

[T, X, Y, Z] = myLorenzSolver([0, 50], [0;1;1.05], 10, 28, 8/3);

"Attempted to access S(2); index out of bounds because 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

Thanks in advance for the help!

kal
  • 37
  • 2
  • 14
  • Do you know how `ode45` uses the derivative function? And how to deal with extra inputs into derivative functions? Read the `ode45` documentation carefully, the answers are all there. – David Dec 05 '15 at 09:59
  • I know that when using ode45 its [ T,Y ] = ode45(function handle, range over which to calculate, and initial estimates). However Im still not sure how to fix this because Im getting error messages about "myLorenz" not having enough input arguments? – kal Dec 07 '15 at 03:09
  • `myLorenz` has 5 inputs, but `ode45` will assume that it has 2 inputs, `t` (or independent variable) and then `y` (dependent variable), in that order. – David Dec 07 '15 at 03:15
  • [T,Y,TE,YE,IE] = solver(odefun,tspan,y0,options).....I see definitions like these however Im not sure what TE, YE, IE would be in my situation. – kal Dec 07 '15 at 03:23

0 Answers0