how can i print 2 function?s results ?
이전 댓글 표시
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
Azzi Abdelmalek
2014년 5월 17일
How did you call your function, give an example
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!