Not enough input arguments.

i am getting error like:
>> run_Lp
xstart =
0 0 1
Not enough input arguments.
Error in l_ext (line 11)
f(2)=-x(1).*x(3)+R*x(1)-x(2);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 106)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in lya (line 19)
[T,Y] = ode45(rhs_ext_fcn,[t t+stept],x,R);
Error in run_Lp (line 9)
lk= lya(n,rhs_ext_fcn,tstart,stept,tend,xstart,R);
>>

3 Comments

run_LP has several inputs. Where do you supply them ?
Just writing "run_LP" in the command window will make MATLAB error.
Guess you want to find the Lyapunov exponents of the Lorenz system?
yes, I want lyapunov exponent v/s parameters plot so, i am trying it

Sign in to comment.

Answers (1)

Do not provide parameters as appended variables in the ODE45 call:
% In lya:
[T,Y] = ode45(rhs_ext_fcn,[t t+stept],x,R);
% ^ nope
Use an anonymous function to provide parameters:
% in run_Lp:
% Nope: rhs_ext_fcn = @l_ext;
R_max=10;
R_min=1; nk=10; tstart=0; stept=0.5; tend=20; xstart=[0 0 1]
R_step=(R_max-R_min)/nk;
R=R_min;
rhs_ext_fcn = @(x, t) l_ext(x, t, R);

6 Comments

I tried your suggestion then also error is coming like
>> run_Lp
xstart =
0 0 1
Unrecognized function or variable 'R'.
Error in run_Lp>@(x,t)l_ext(x,t,R) (line 4)
rhs_ext_fcn=@(x,t) l_ext(x,t,R);R_max=10;R_min=1;nk=10;tstart=0;stept=0.5;tend=20;xstart=[0 0 1]
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 106)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in lya (line 19)
[T,Y] = ode45(rhs_ext_fcn,[t t+stept],xstart);
Error in run_Lp (line 9)
lk= lya(n,rhs_ext_fcn,tstart,stept,tend,xstart);
>>
@nune pratyusha: this line:
rhs_ext_fcn=@(x,t) l_ext(x,t,R);
requires R to be already defined. However in your code you define R nine lines later, which will not work.
Solution: define R before that line:
R = .. % <---- define R
rhs_ext_fcn=@(x,t) l_ext(x,t,R); % <---- before you refer to R here
if i am giving R=1:0.1:20;
it showing error like
>> run_Lp
xstart =
0 0 1
Index exceeds the number of array elements. Index must not exceed 3.
Error in l_ext (line 5)
X= [x(4) x(7) x(10);
Error in run_Lp>@(t,x)l_ext(t,x,R) (line 7)
rhs_ext_fcn=@(t,x) l_ext(t,x,R);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 152)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in lya (line 19)
[T,Y] = ode15s(rhs_ext_fcn,[t t+stept],xstart);
Error in run_Lp (line 10)
lk= lya(n,rhs_ext_fcn,tstart,stept,tend,xstart);
>>
@nune pratyusha: originally you defined
R=R_min;
why are you now defining it as
R=1:0.1:20;
?
In any case, the cause of the error is clear: inside L_EXT() you are trying to access elements 4-10 of array x which only has 3 elements. Trying to access non-existent array elements throws an error. This is to be expected.
You defined XSTART to have three elements, therefore the x array inside the objective function will also have three elements.
I strongly recommend that you have only one assignment per line, and align your code consistently.
i changed the code but i didn't get any output
function run_Lp(n,rhs_ext_fcn,tstart,stept,tend,xstart,nk);
figure()
hold on;
n=3;
R_max=10;R_min=1;nk=10;tstart=0;stept=0.5;tend=20;xstart=[0 0 1]
R_step=(R_max-R_min)/nk;
R=1:R_step:10; R =R+R_step;
rhs_ext_fcn=@(t,x) l_ext(t,x,R);
while R<=R_max
lk= lya(n,rhs_ext_fcn,tstart,stept,tend,xstart);
R =R+R_step;
plot(R,lk);
end
@nune pratyusha: the WHILE loop never runs.
Consider your variables:
R_max =
10
R =
1.9000 2.8000 3.7000 4.6000 5.5000 6.4000 7.3000 8.2000 9.1000 10.0000 10.9000
which you use on this line:
while R<=R_max
The WHILE documentation states "An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false."
Question: are all of the expression elements you provide to WHILE true?
Answer: no (because 10.9 is greater than 10, so that last element will be false).
So your WHILE loop never runs.
I doubt that R should be a vector.
I strongly recommend that you have one assignment per line, and consistently align your code.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 14 Jun 2022

Edited:

on 15 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!