Why is this showing this undefined error for "^" input argument?

function output=bisection(a,b,fun,tol)
a=15
b=36
fun=@y^2-5*y+6
tol=.00002
end
Undefined operator '^' for input arguments of type 'function_handle'.
Error in bisection (line 9)
fun=@y^2-5*y+6

댓글 수: 1

Why are you assigning a value to fun which was passed in as a parameter? Why are you assigning values to the other variables, all of which are expected to be passed in?

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

답변 (1개)

Sindar
Sindar 2020년 1월 23일
편집: Sindar 2020년 1월 23일
fun=@(y) y.^2-5*y+6
is the syntax you want

카테고리

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

질문:

AJ
2020년 1월 23일

댓글:

2020년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by