I am trying to compile the roots calculated from a bisection method function and an incremental search method function. The output of nb from the incremental search function continually appears even when I suppress the incremental search function.
function [X] = manyRoots(func,a,b,ns,tol)
y = bisect(func,a,b,tol);
z = incsearch(func,a,b,ns);
[X]=[y,z];
end
I am trying to supress the nb from this function.
function xb = incsearch(func,xmin,xmax,ns)
if nargin < 3, error('at least 3 arguments required'), end
if nargin < 4, ns = 50; end
x = linspace(xmin,xmax,ns);
f = func(x);
nb = 0; xb = [];
for k = 1:length(x)-1
if sign(f(k)) ~= sign(f(k+1))
nb = nb + 1;
xb(nb,1) = x(k);
xb(nb,2) = x(k+1);
end
end
if isempty(xb)
disp('no brackets found')
disp('check interval or increase ns')
else
disp('number of brackets:')
disp(nb)
end
I am trying to suppress the number of brackets that shows up above my answer X.
0 Comments
Sign in to comment.