Too many input arguments Fsolve

Error using ==> derofexpexp2
function[derofexpexp1b,derofexp1a,derofexpexp1a]=derofexpexp2(rvar,eqdif,eqpardif,indexp1,indexpexp1)
Too many input arguments.
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Error in ==> paragexpexp at 56
zeroofder2p=fsolve('derofexpexp2',finnoearth(finpeakh,1),options2a,[],eqdif,eqdf3,indexpl1,indexexp1);

Answers (1)

The objective function for fsolve is currently not defined to take more than one input.
Historically, extra parameters in the fsolve call were added as arguments to the objective function. That syntax has been obsolete and undocumented since MATLAB 5.1 and might or might not work.
If it does work, then in your call
fsolve('derofexpexp2',finnoearth(finpeakh,1),options2a,[],eqdif,eqdf3,indexpl1,indexexp1);
the argument finnoearth(finpeakh,1) would correspond to x0, and the argument options2a would correspond to options, leaving [], eqdif, eqdf3, indexp11, and indexexp1 as extra arguments. That would be 5 extra arguments in addition to the x argument, which would lead to 6 arguments passed to the function. But your function is only defined to take 5 arguments.
Please read http://www.mathworks.com/help/matlab/math/parameterizing-functions.html . (Unless, of course, you are still using MATLAB 4.x, which would be pretty major information that you would have been expected to mention already.)

9 Comments

1) this problem occurs only in Matlab 7 , i have no issues in matlab 6.5
2) i have tried to remove the [] yet having the same problem zeroofder2p=fsolve('derofexpexp2',finnoearth(finpeakh,1),options2a,eqdif,eqdf3,indexpl1,indexexp1); . Please assist.
Parameterize your function the way shown in the link.
Ana Royce
Ana Royce on 19 Aug 2016
Edited: Ana Royce on 20 Aug 2016
refresh to Matlab , please help me
1) should insert additional function argument like this eg. derofexpexp2( x,rvar,eqdif,eqpardif,indexp1,indexpexp1) without decreasing the following : fsolve('derofexpexp2',finnoearth(finpeakh,1),options2a,[],eqdif,eqdf3,indexpl1,indexexp1);
3) as per knowledge fsolve(only take 3 arguments) feval(funfcn{3},x,varargin{:});
zeroofder2p = fsolve(@(x) derofexpexp2(x, eqdif, eqdf3, indexpl1, indexexp1), finnoearth(finpeakh,1), options2a);
Thanks for your reply. However system prompt following error . I doubt due to [] options argument . How shall i go about it? Please help
??? Error using ==> optimset at 167 Expected argument 1 to be a string parameter name or an options structure created with OPTIMSET.
Error in ==> createOptionFeedback at 19 options = optimset(options);
Error in ==> fsolve at 353 optionFeedback = createOptionFeedback(options);
Error in ==> paragexpexp at 59 zeroofder2p = fsolve(@(x) derofexpexp2(x, eqdif, eqdf3, indexpl1, indexexp1), finnoearth(finpeakh,1), options2a);
Error in ==> expexpfuni4e at 345 paragexpexp
I see you passing in options2a in the options argument, but you have not shown what you assign to options2a.
Note: I was assuming from the name that it was indeed the options parameter and not one of your additional parameters like eqdf3
i have defined value for options2a as : and attached code of two function file ...please review and assist me . i need to submit my work by tomorrow. Advance thanking
my paragexpexp.m (file that im calling in main)
%This will calculate the derivatives of the exp functions in expexp.
format long e
eq4=0;
eq4a=0;
%load fileofsechpar
%Not needed since it is executed directly after the profile model.
syms Hmaxexpa Semexpa Nemaxexpa Hmpar Sempar Nempar
rvar='r';
options2a=[0 0 0 0 0 0 0 0 0 0 0 0 0 30000 0 0 0 0];
for ki3=1:1:indexpl1;
eq1='[(rvar-Hmaxexpa)/(Semexpa)]';
eq1=sym(eq1);
eq2=subs(eq1,{Hmaxexpa,Semexpa},{Hmaxexpl(1,ki3),Semexpl(1,ki3)});
eq2=vpa(eq2,32);
%eq2=eval(eq1);
eq2a='Nemaxexpa*(exp(-eq2^2))';
eq2a=subs(eq2a,Nemaxexpa,Nemaxexpl(1,ki3));
eq2a1=vpa(eq2a,32);
eq2b=subs(eq2a1,eq2,'eq2');
eqdf2=diff(eq2b);
eq4=eq4+eq2b;
eq4a=eq4a+eqdf2;
sizeofeq(ki3,1)=length(eqdf2(1,:));
eqdif(ki3,1)=eqdf2;
eqmod(ki3,1)=eq2b;
end
eq5=diff(eq4);
eq5=vpa(eq5,32);
save eq5s eq5
eq5a=eq4a;
eqp2bb=0;
eqp2aa=0;
for ki7=1:1:indexexp1;
term1='[(rvar-Hmpar)/(Sempar)]';
trmev=subs(term1,{Hmpar,Sempar},{Hmaxexpexp2(1,ki7),Semexpexp2(1,ki7)});
eqp1='Nempar*exp(-trmev^200)';
eqp2=subs(eqp1,'trmev',trmev);
eqp22=subs(eqp2,'Nempar',Nemaxexpexp2(1,ki7));
eqp2mod=subs(eqp2,{Hmpar,Sempar,Nempar},{Hmaxexpexp2(1,ki7),Semexpexp2(1,ki7),Nemaxexpexp2(1,ki7)});
eqp2a=vpa(eqp22,32);
eqp2b=diff(eqp2a);
eqp2aa=eqp2aa+eqp2a;
eqp2bb=eqp2bb+eqp2b;
%eq1p='-50*Nempar/(Sempar)*term1^49*exp(-term1^50)';
eq1p='-50*Nempar/(Sempar)*trmev^49';
eq2p=subs(eq1p,'trmev',trmev);
eq3p=subs(eq2p,{Hmpar,Sempar,Nempar},{Hmaxexpexp2(1,ki7),Semexpexp2(1,ki7),Nemaxexpexp2(1,ki7)});
eq4p=vpa(eq3p,32);
eqdf3=diff(eqp2mod);
eqpardif(ki7,1)=eqp2b;
eqpardif1(ki7,1)=eq4p;
end
zeroofder2p = fsolve(@(x) derofexpexp2(x,eqdif, eqdf3, indexpl1, indexexp1), finnoearth(finpeakh,1), options2a);
rfound2p=zeroofder2p;
totmaxval=0;
for ki3=1:1:indexpl1;
rv=rfound2p;
valoffun(ki3,1)=subs(eqmod(ki3,1),'rvar',rv);
totmaxval=totmaxval+(valoffun(ki3,1));
end
totmaxval=subs(totmaxval)
%Subs also used to transform symbolic to numeric.
totmaxvalp=0;
for ku3=1:1:indexexp1;
rvp=Hmaxexpexp2(1,indexexp1);
valoffunp(ku3,1)=subs(eqp2mod(ku3,1),'rvar',rvp);
totmaxvalp=totmaxvalp+(valoffunp(ku3,1));
end
totmaxvalp=subs(totmaxvalp)
%Subs also used to transform symbolic to numeric.
totmaxvalt=totmaxval+totmaxvalp
return
my derofexpexp2.m
function[derofexpexp1b,derofexp1a,derofexpexp1a]=derofexpexp2(rvar,eqdif,eqpardif,indexp1,indexpexp1)
derofexp1a=0;
for ki3=1:1:indexp1;
derofexp1aa(ki3,1)=eval(eqdif(ki3,1));
derofexp1a=derofexp1aa(ki3,1)+derofexp1a;
end
derofexpexp1a=0;
for ku3=1:1:indexpexp1;
derofexpexp1aa(ku3,1)=eval(eqpardif(ku3,1));
derofexpexp1a=derofexpexp1aa(ku3,1)+derofexpexp1a;
end
rvar;
derofexpexp1b=derofexpexp1a+derofexp1a;
return
Your options2a is a numeric vector, not an options structure. Is it intended to act as the initial values of the vector being solved on? If it is, then what is the role of finnoearth(finpeakh,1) ?
Your function uses parameters named rvar, eqdif, eqpardif, indexp1, and indexpexp1. How do your calling parameters finnoearth(finpeakh,1), options2a, eqdif, eqdf3, indexpl1, and indexexp1 correspond to each of those? Some of the matches look pretty obvious, but you have 6 inputs and only 5 parameters.
Noted, understood. will work. Thank you.

Sign in to comment.

Asked:

on 18 Aug 2016

Commented:

on 25 Aug 2016

Community Treasure Hunt

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

Start Hunting!