how can i print 2 function?s results ?
Show older comments
the answer is only X and not the niter, why ?
function [X,niter] = bisection2(intervallo,tol)
niter = 1;
if intervallo(1) < intervallo(2)
a = intervallo(1);
b = intervallo(2);
elseif intervallo(1) == intervallo(2)
X = intervallo(2);
else a = intervallo(2);
b = intervallo(1);
end
X0 = (a + b)/2;
if f(a) * f(b) < 0
if abs(f(X0)) < tol
end
while abs (f(X0)) > tol
if f(X0) * f(a) < 0
b = X0;
else
a =X0;
end
X0 = (a + b)/2 ;
niter = niter + 1;
end
X = X0 ;
elseif f(a) * f(b) == 0
if f(a) == 0
X = a;
else
X = b;
end
end
1 Comment
Azzi Abdelmalek
on 17 May 2014
How did you call your function, give an example
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB 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!