FZERO requires at least two input arguments
Show older comments
Hey, I need help
function [y,fx,x] = solveNadiabxy(al,bt,ga,kc,yc)
warning off; midtol = 10^-13;
fzero ltol = 10^-14; mid = 1;
change if critical options = optimset('dis',[].'tolx', ltol);
x0 = fzero(@Nadiab,0,options,al,bt,ga,kc,yc);
x1 = fzero(@Nadiab,1,options,al,bt,ga,kc,yc);
if abs(x0 - x1) > 10^-10
check with graph xmid = fzero(@Nadiab,[1.01*x0,0.99*x1], options,al,bt,ga,kc,yc);
else, xmid = (x0+x1)/2;
end
x = [x0 xmid x1];
y = sort ((1+kc*yc + bt*(1-x))/(1+kc));
fx = Nadiab (x,al,bt,ga,kc,yc);
function f = Nadiab(x,al,bt,ga,kc,yc)
f = 1 - x - al*exp(-ga*(1+kc)./(1+kc*yc + bt *(1 - x))) .* x;
this is the code that i used, but everytime want to solve the problem it came Fzero requires arguments
Accepted Answer
More Answers (2)
KSSV
on 28 May 2020
You have to provide inputs to the function. Save those functions in a file, in a folder.
al = give your value ;
bt = give your value ;
ga = give your value ;
kc = give your value ;
yc = give your value ;
[y,fx,x] = solveNadiabxy(al,bt,ga,kc,yc) ;
9 Comments
Andreas Nathaniel
on 28 May 2020
Andreas Nathaniel
on 28 May 2020
KSSV
on 28 May 2020
You make that folder as the present working directory.....use cd or run the function, it will ask your permission either to addpath or change the directory.
Andreas Nathaniel
on 28 May 2020
KSSV
on 28 May 2020
Thanks is accepting the asnwer.. :)
Andreas Nathaniel
on 28 May 2020
KSSV
on 28 May 2020
Show me what have you given input variables.
Andreas Nathaniel
on 28 May 2020
Andreas Nathaniel
on 28 May 2020
Steven Lord
on 28 May 2020
Edited: Steven Lord
on 28 May 2020
I have a number of pieces of feedback on this code. It looks like it was written for an older version of MATLAB and was copied incorrectly from the textbook.
function [y,fx,x] = solveNadiabxy(al,bt,ga,kc,yc)
warning off; midtol = 10^-13;
Don't turn off all warnings, especially if you never turn them back on. MATLAB can help you understand where you may be doing something you shouldn't be, but not if you tell it to shut up.
fzero ltol = 10^-14; mid = 1;
This is almost certainly not what you wanted to write here. This calls fzero with three pieces of text as inputs.
change if critical options = optimset('dis',[].'tolx', ltol);
This attempts to call a function named change with several pieces of text as input. Perhaps the "change if critical" part was supposed to be a comment and the optimset call was supposed to be on the next line, like this?
% This section added by Steve Lord, not part of the original code
% change if critical
options = optimset('dis', [], 'tolx', ltol);
x0 = fzero(@Nadiab,0,options,al,bt,ga,kc,yc);
x1 = fzero(@Nadiab,1,options,al,bt,ga,kc,yc);
While this works, it's an older syntax for fzero. That syntax is supported for backwards compatibility and is no longer documented. Instead you should use one of the techniques given on this documentation page to pass the additional parameters into your Nadiab function.
if abs(x0 - x1) > 10^-10
check with graph xmid = fzero(@Nadiab,[1.01*x0,0.99*x1], options,al,bt,ga,kc,yc);
This tries to call a function named check with several pieces of text as input. Like the "change if critical" section, it looks like the first part is supposed to be a comment. It also uses the older fzero syntax.
2 Comments
Andreas Nathaniel
on 28 May 2020
Steven Lord
on 28 May 2020
The newest what? The newer syntax for fzero? See that documentation page I linked for some of the currently recommended ways to pass additional parameters into the function you pass into fzero.
Categories
Find more on Keypoint Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!