Help!!! Mysterious FSOLVE InputOutputModel/vertcat Error!
Afficher commentaires plus anciens
I'm new to MATLAB and I keep getting this error when I try to solve a system of 10 equations in 10 unknowns:
Error using InputOutputModel/vertcat (line 48)
In "[M1;M2]", M1 and M2 must have the same number of
inputs/columns.
Error in fpiss_fun (line 25)
f = [
Error in @(x)fpiss_fun(x,param)
Error in fsolve (line 218)
fuser = feval(funfcn{3},x,varargin{:});
Error in Sample (line 14)
x=fsolve(f,x0)
Caused by:
Failure in initial user-supplied objective function
evaluation. FSOLVE cannot continue.
Relevant code:
clear all;
clc;
param = fpi_parameters;
options = optimoptions('fsolve','Display','iter');
x0 = [2.1;1.8;.95;12;9;10;.01;.16;.001;3];
f=@(x)fpiss_fun(x,param);
x=fsolve(f,x0)
___________
function param = fpi_parameters()
param.bet = .99;
param.ak = .005;
param.an = .05;
param.lamk = .01;
param.lamn = .1;
param.epk = .5;
param.epn = .6;
param.dele = .02;
param.delu = .01;
param.chik = 1;
param.chin = 1;
param.alph = .3;
param.zss =1;
param.wss =1.45;
param.rss =0.04;
______________
function f = fpiss_fun(x,param)
%Allows referencing parameters by fieldnames instead of param.fieldname
nms = fieldnames(param);
for j = 1:length(nms)
eval([nms{j} '=' 'param.' nms{j} ';'])
end
%Renaming endogenous variables
y=x(1);
c=x(2);
l=x(3);
n=x(4);
ke=x(5);
ku=x(6);
vk=x(7);
vn=x(8);
thetk=x(9);
thetn=x(10);
%Declaring the system to be solved for (y c l n ke ku vk vn thetk thetn)
f = [
wss*n+rss*ke+lamk*(1-dele)*ke+ku-c-l;
y-zss*n^(alph)*ke^(1-alph);
ke-(1-dele)*(1-lamk)*ke-chik*thetk^(epk)*l;
ku-(1-chik*thetk^(epk))*(1-delu)*l;
n-(1-lamn)*n-chin*thetn^(epn)*(1-n);
ak/(chik*thetk^(epk-1))-bet*(zss*(1-alph)*n^alph*ke^(-alph)-rss+(1-lamk)*(1-dele)*ak/(chik*thetk^(epk-1)));
an/(chin*thetn^(epn-1))-bet*(zss*alph*n^(alph-1)*ke^(1-alph)-wss+(1-lamn)*an/(chin*thetn^(epn-1)));
thetn-vn/(1-n);
thetk-vk/l;
(1-(1-chik*thetk^(epk))*(1-delu)*bet)/(chik*thetk^(epk))*(1-bet*(1-dele)*(1-lamk))-bet*(rss+lamk*(1-dele))
];
Any ideas why this isn't working? Thanks!!!
1 commentaire
Alan Weiss
le 31 Mai 2013
Please edit your post using the {}Code tool as appropriate so we can read it.
Alan Weiss
MATLAB mathematical toolbox documentation
Réponse acceptée
Plus de réponses (1)
Alan Weiss
le 31 Mai 2013
I am not sure what your code does. Can you please try to execute
testvalue = fpiss_fun(x0,param)
where x0 is your initial point? Do you get a result testvalue?
Alan Weiss
MATLAB mathematical toolbox documentation
Catégories
En savoir plus sur Support Vector Machine Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!