fzero help please I need value of y...the complete code is as follows
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I wrote following code in matlab.
% declare global variables
global bcr vc locr rc rb wb
% define given parameters
bcr = 0.713;
vc = 0.18;
locr=0.092;
rc = 0.056;
rb = 0.008;
wb = 1.19;
% compute the root of wc f(wc)=0.0 using fzer0 function
[y,fval,exitflag,output] = fzero('myfun_y',[0.008,0.056])
function file is as follows:
% function file to calculate value of y at which f(y) = 0.0 using fzero
function f = myfun_y(y)
% declare global variables
global locr rb vc rc wb bcr
% define function f(y)
f1 = ((y-rb)/(locr*(locr-y)*(locr-rb)))+((1/locr^2)*log((y*(locr-rb))/(rb*(locr-y))));
f2 = (y*(locr-y))*((1.+vc)+(1.-vc^2)*(rc^2-y^2)/(rc^2+y^2));
f3 = wb*bcr;
f = f1*f2-f3;
end
*When I run, this code I got following message.
Error using fzero (line 233)
FZERO cannot continue because user supplied function_handle ==> myfun_y
failed with the error below.
Not enough input arguments.
Error in compute_y (line 22)
[y,fval,exitflag,output] = fzero('myfun_y',[0.008,0.056]) *
ANy idea, what is going on...I need value of y between 0.008 and 0.56...
*I am hating fzero now...it is giving me hard time.
0 Commenti
Risposte (1)
Walter Roberson
il 19 Apr 2013
Experiment with replacing
[y,fval,exitflag,output] = fzero('myfun_y',[0.008,0.056])
with
[y,fval,exitflag,output] = fzero(@myfun_y, [0.008,0.056])
3 Commenti
Walter Roberson
il 19 Apr 2013
It is the log* that is the problem. Not enough input arguments to log.
Vedere anche
Categorie
Scopri di più su Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!