simple fsolve problem...

조회 수: 15 (최근 30일)
John
John 2012년 5월 31일
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!

답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 31일
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)

카테고리

Help CenterFile Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by