how can i print 2 function?s results ?
Afficher commentaires plus anciens
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 commentaire
Azzi Abdelmalek
le 17 Mai 2014
How did you call your function, give an example
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!