using explcit parameters in fsolve gives error, how to solve this?
Mostrar comentarios más antiguos
I have numerical values assigned to several parameter.
Using these parameters, I want solve fsolve such as below.
But it keeps giving error messages saying that the parameters are
not defined. Should I write every numbers instead of characters in
the function? Help me, please!
g=0.03; %gamma
b=0.45; %beta
a=0.3; %alpha
aa=2.5222; %1+alphabeta/beta
rho=0.5; %rho
r=1+rho*b/(1+a*b); %1+rho/1+alphabeta
th1=0.000045; %theta1
th2=0.000037; %theta2
R=900; %Resource
S=210; %S_-1
B=1/(1-a-g); %1/1-alpha-gamma
A12=1.5;
A11=1.2;
A02=1.9;
A01=1.8;
F = @(E)[2.52*( g/E(2) - r*(th1+W*th2) ) - g/E(1) + (th1+W*th2);
2.52*( g/E(4) - r*(W*th1+th2) ) - g/E(3) + (W*th1+th2);
R - ( E(1)+E(2)+E(3)+E(4) );
((exp( -th2*( rho*S +E(2) + E(4) ) ))/(exp( -th1*( rho*S +E(2) + E(4) ) ))*A02/A01)^(B)-E(4)/E(2);
((exp( -th2*( rho*( rho*S +E(2) + E(4) ) +E(1) + E(3) ) ))/(exp( -th1*( rho*( rho*( rho*S +E(2) + E(4) ) +E(1) + E(3) ) )))*A12/A11)^(B)-E(1)/E(3);
W-E(4)/E(2);
E(4)/E(2)-E(3)/E(1)];
E0=[300];
options=optimset('Display','iter');
E=fsolve(@planerenergy, E0, options)
ps. I also tried to make the function as seperate function such as
xx.m file. But it still gives the same error message such as
??? Undefined function or variable 'g'.
Error in ==> planerenergy at 2 F = [2.52*( g/E(2) - r*(th1+W*th2) ) - g/E(1) + (th1+W*th2);
Error in ==> fsolve at 248 fuser = feval(funfcn{3},x,varargin{:});
Error in ==> calibration0329 at 27 E=fsolve(@planerenergy, E0, options) Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Respuesta aceptada
Más respuestas (1)
Sean de Wolski
el 30 de Mzo. de 2012
1 voto
Whatever planerenergy is at line two, it doesn't have g defined.
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!