fzero help please I need value of y...the complete code is as follows
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2013년 4월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!