0
votes

I am dealing with the following code:

function opemployment=eqns(unknown);
global kappa varphi lgamma beta r delta s x b e theta v;
h=unknown(1);
gamma=unknown(2);
opemployment(1)=(h^(gamma-1))*((1-kappa)*((lgamma*(varphi^beta))/(gamma*kappa*beta+1-kappa))*h^(gamma*beta-gamma)-(r+delta+s)*(s^(gamma-1))*x^(-gamma));
opemployment(2)=(1-kappa)*(b-e+(kappa/(1-kappa))*theta*v^(gamma-1));

and then call:

close all; clear all;
global kappa varphi lgamma beta r delta s x b e theta v;
kappa = 0.1;
varphi = 2;
lgamma = 3;
beta = 0.9;
r = 2;
delta = 2 ;
s = 3;
x = 5;
b = 4;
e =3;
theta = 3 ;
v = 2;
guess = [0.7,0.3];
sol=fsolve('eqns',guess)

Yet, I receive the following error: 'Error using feval Undefined function 'eqns' for input arguments of type 'double'.

Error in fsolve (line 217)
        fuser = feval(funfcn{3},x,varargin{:});

Caused by:

Failure in initial user-supplied objective function evaluation. 
FSOLVE cannot continue.

I am a total MATLAB beginner and have no clue where the error lays.

1

1 Answers

1
votes

You are not specifying the first parameter of fsolve correct. Taking a look at the documentation is always very useful when you're in doubt about how to call a function. For fsolve, it's here: http://www.mathworks.com/help/optim/ug/fsolve.html

In your case, for your fsolve statement, you must do this:

sol=fsolve(@eqns,guess)

fsolve expects a function handle to your function that you want to solve, not the actual name of the function itself.