Afficher commentaires plus anciens
I'm working on solving for the values of a series of parameters that are from a set of equations. While I have tried following every example I can find for fsolve, none have been particularly helpful. I've past the code from my m file below. Any help is appreciated. THANKS!
function F=calibrate(X)
%known variables;
nm = 0.031;
se = 0.108;
ne = 0.862;
c = 0.091;
ke = 0.545;
km = 0.040;
m = 0.097;
l = 0.333;
phi = 0.045;
A = 0.017;
B = 0.048;
%unknown parameters;
delta=X(1);
alpha=X(2);
gamma=X(3);
tau=X(4);
theta=X(5);
zeta1=X(6);
zeta2=X(7);
zeta3=X(8);
eta=X(9);
omegae = X(10);
omegam = X(11);
beta = X(12);
F(1) = A*((ke^alpha)*(ne^(1-alpha)))^(1-gamma) * m^gamma - c - ke*phi - km*phi +(ke+km)*(1 - delta);
F(2) = B*(theta * (km^tau) + (1-theta)*(nm^tau))^(1/tau) -m;
F(3) = omegae*se + omegam*nm - phi;
F(4) = 1 - ne - nm - se -l;
F(5) = zeta1 * ke^(alpha*(1-gamma))* ne^(-alpha - gamma*(1- alpha))*m^gamma - c;
F(6) = (gamma/eta)*A*B*(ke^(alpha*(1-gamma)))*(ne^((1-alpha)*(1-gamma)))*(nm^(tau-1))*(m^(gamma - tau)) + c*(omegae /omegam) - c;
F(7) = zeta2 * (ke^((alpha -1)-(gamma*alpha)))*(ne^((1-alpha)*(1-gamma)))*(m^gamma)+ zeta3 - phi;
F(8) = zeta3 - beta * gamma * theta * A* B*(ke^(alpha*(1-gamma)))*(ne^((1-alpha)+(1-gamma)))*(km^(tau-1))*(m^(gamma-tau)) - phi;
F(9) = beta*omegae*(1-l) - phi;
F(10) = (A*(1-gamma)*(1 - alpha))/eta - zeta1;
F(11) = beta*A*(1-gamma)*alpha - zeta2;
F(12) = beta*(1-delta)- zeta3;
1 commentaire
Doug Hates Squirrels
le 26 Avr 2011
Réponse acceptée
Plus de réponses (1)
Lidianne Mapa
le 14 Jan 2018
Hello dear, I'm with similar problem. This is my function:
if y==1
N1{y}=[(diff(Beta{y}(:,1),qsol(1))) diff(Beta{y}(:,1),qsol(2)) diff(Beta{y}(:,1),qsol(3));
(diff(Beta{y}(:,2),qsol(1))) diff(Beta{y}(:,2),qsol(2)) diff(Beta{y}(:,2),qsol(3));
(diff(Beta{y}(:,3),qsol(1))) diff(Beta{y}(:,3),qsol(2)) diff(Beta{y}(:,3),qsol(3))]
N2{y}=[(diff(Alfa{y}(:,1),qsol(1))) diff(Alfa{y}(:,1),qsol(2)) diff(Alfa{y}(:,1),qsol(3));
(diff(Alfa{y}(:,2),qsol(1))) diff(Alfa{y}(:,2),qsol(2)) diff(Alfa{y}(:,2),qsol(3));
(diff(Alfa{y}(:,3),qsol(1))) diff(Alfa{y}(:,3),qsol(2)) diff(Alfa{y}(:,3),qsol(3))]
else
N1{y}=[(diff(Beta{y}(:,1),qsol(4))) diff(Beta{y}(:,1),qsol(5)) diff(Beta{y}(:,1),qsol(6));
(diff(Beta{y}(:,2),qsol(4))) diff(Beta{y}(:,2),qsol(5)) diff(Beta{y}(:,2),qsol(6));
(diff(Beta{y}(:,3),qsol(4))) diff(Beta{y}(:,3),qsol(5)) diff(Beta{y}(:,3),qsol(6))]
N2{y}=[(diff(Alfa{y}(:,1),qsol(4))) diff(Alfa{y}(:,1),qsol(5)) diff(Alfa{y}(:,1),qsol(6));
(diff(Alfa{y}(:,2),qsol(4))) diff(Alfa{y}(:,2),qsol(5)) diff(Alfa{y}(:,2),qsol(6));
(diff(Alfa{y}(:,3),qsol(4))) diff(Alfa{y}(:,3),qsol(5)) diff(Alfa{y}(:,3),qsol(6))]
end
end
KNL1=[N1{1},zeros(size(TMgmod{1},1),size(TMgmod{1},2)); zeros(size(TMgmod{1},1),size(TMgmod{1},2)) N1{2}];
KNL2=[[N2{1},zeros(size(TMgmod{1},1),size(TMgmod{1},2)); zeros(size(TMgmod{1},1),size(TMgmod{1},2)) N2{2}]] KTOTAL=1/2*KNL1+1/3*KNL2+Ktotal Forca=[10;10;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0] TFORCA=Tcbacop'*Forca; x0=inv(Ktotal)*TFORCA fun_sym =rootedo(qsol,KTOTAL,TFORCA); fun = matlabFunction(fun_sym, 'vars', {qsol.'}); fsolve(fun,x0, optimset('MaxFunEvals', 3000,'MaxIter', 800, 'FunValCheck', 'on', 'PlotFcns', @optimplotfval))
function [F]=rootedo(qsol,KTOTAL,TFORCA) F=KTOTAL*qsol'-TFORCA
This error:
fsolve stopped because the relative size of the current step is less than the default value of the step size tolerance squared, but the vector of function values is not near zero as measured by the default value of the function tolerance.
ans = 1.0e-08 * 0.5447 0.1506 0.0561 0.5447 0.1506 0.0561
Can you help me please?
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!