fsolve - solving for a steady state
Mostra commenti meno recenti
I have a system of 4 unknowns and 4 equations of which I can cancel down to a system of 2 equations and 2 unknowns which leads to a trivial solution to the other 2 unknowns.
The two equations are:
(0.99)*(0.3*(k^0.3)*(n^0.7) + 0.975) = 1
and
((0.21)*(k^0.3)*(n^-0.3))/((k^0.3)*(n^0.7) - (0.025*k)) = 0.7/(1-n)
I am obviously looking to solve for k and h and I know that h is bounded by 0 and 1 (labour-leisure choice per period). I attempt to solve this via fsolve and this is my code:
function [ F ] = myfun(k,n)
% the system of 2 equations to solve for in vector F
F = [((((0.21)*(k.^0.3)*(n.^-0.3))/((k.^0.3)*(n.^0.7)- 0.025*k)) - ((0.7)/(1-n)));
(((0.99)*(0.3*(k.^-0.7)*(n.^0.7) + 0.975)) - 1)];
end
%%why was I told to use .^ for powers since I thought k and n were both scalar and I am looking to be returned a scalar?
and the script:
F0 = [5; 0.5]';
options = optimoptions('fsolve','Display','iter'); % Option to display output
X = fsolve(@myfun,F0,options); % Call solver
When I run this through Matlab I get this error:
Error using myfun (line 5)
Not enough input arguments.
Error in fsolve (line 219)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
And quite honestly, I'm not sure where it's going wrong and why it is saying there are not enough input arguments, any guidance is appreciated.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!