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 件のコメント

Walter Roberson
Walter Roberson 2020 年 1 月 23 日
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 日

0 投票

fun=@(y) y.^2-5*y+6
is the syntax you want

カテゴリ

ヘルプ センター および File ExchangeEntering 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