Undefined function or variable 'bisection'.

function [x,e] = mybisect (f,a,b,n)
c = f(a);
z = f(b);
if (f(a)*f(b) > 0)
error ('Function has ame sign at both endpoints')
end
disp(' x y')
for i = 1:n
x = (a+b)/2;
y = f(x);
disp([ x y])
if y == 0.0
a = x;
b = x;
break
end
if c.y < 0.0
b = x;
else
a = x;
end
end
x = (a+b)/2;
e = (b-a)/2;
end

댓글 수: 1

Brian Reinhard
Brian Reinhard 2021년 3월 15일
when i use:
>> f=inline('@(x) cos*x+sin*x','x');
>> akar=bisection(f,2,4,20,1e-2)
it will show:
Undefined function or variable 'bisection'.
Pls someone can tell me where is the problem?

댓글을 달려면 로그인하십시오.

답변 (1개)

James Tursa
James Tursa 2021년 3월 15일
편집: James Tursa 2021년 3월 15일

0 개 추천

From the error message, it looks like you are calling the function using the name "bisection", but the actual name of the function is "mybisect". Hence the error.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

태그

질문:

2021년 3월 15일

편집:

2021년 3월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by