simple fsolve problem...
14 views (last 30 days)
Show older comments
I'm new to MATLAB and I'm trying to solve a nonlinear system of two (large) equations in two unknowns, but I keep getting the "Too many input arguments" error. I've posted the call file, the function and the error, respectively, below. Any suggestions would be welcome. Thanks!!
clear all;
clc;
a=0.3;
e=0.3;
c=1;
z=1;
r=0.02;
p=[a,e,c,z,r];
x0=[.5;.5];
options=optimset('Display','iter');
x=fsolve(@opt_tax_solve,x0,options,p);
disp('x = '); disp(x);
_________
function F=opt_tax_solve(x)
t_l=x(1);
t_k=x(2);
a=p(1);
e=p(2);
c=p(3);
z=p(4);
r=p(5);
F=[1/(t_l - 1) - (a*((z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1) - 1)*(a - 1))/((r - 1)*(a*(e - 1) + 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1))) + (a*e*z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1))*(t_k - 1))/((a + c)*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(t_l - 1)^2*(a*(e - 1) + 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1) + 1)))*(e - 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1)))/(z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1))) + (a*e*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c))*(t_k - 1))/((1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(a - 1)*(t_l - 1)^2) - (a*e*(t_k - 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^c)/((a + c)*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(a - 1)*(t_l - 1)^2);
(a*((a*e*z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1) - 1))/((r - 1)*(a*(e - 1) + 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1))) + (a*e*z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1)))/((a + c)*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(t_l - 1)*(a*(e - 1) + 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1) + 1)))*(e - 1)*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^((a - 1)/(a*(e - 1) + 1)))/(z^(1/(a*(e - 1) + 1))*((t_l*(a - 1) - a*e*t_k)/(r - 1))^(1/(a*(e - 1) + 1))) - (a*e*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))/((1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(a - 1)*(t_l - 1)) + (a*e*(1/(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c)))^c)/((a + c)*(1 - (a*e*(t_k - 1))/((a - 1)*(t_l - 1)))^(1/(a + c) + 1)*(a - 1)*(t_l - 1));
];
_________
??? Error using ==> opt_tax_solve
Too many input arguments.
Error in ==> fsolve at 253
fuser = feval(funfcn{3},x,varargin{:});
Error in ==> call_opt_tax at 16
x=fsolve(@opt_tax_solve,x0,options,p);
Caused by:
Failure in initial user -supplied objective function evaluation. FSOLVE cannot continue.
Let me know if I'm missing something obvious. Thanks again!
0 Comments
Answers (1)
Walter Roberson
on 31 May 2012
Change
x=fsolve(@opt_tax_solve,x0,options,p);
to
x = fsolve(@(x) opt_tax_solve(x, p), x0, options);
Change
function F=opt_tax_solve(x)
to
function F = opt_tax_solve(x, p)
0 Comments
See Also
Categories
Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!