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

5 Ansichten (letzte 30 Tage)
AJ
AJ am 23 Jan. 2020
Kommentiert: Walter Roberson am 23 Jan. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 23 Jan. 2020
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sindar
Sindar am 23 Jan. 2020
Bearbeitet: Sindar am 23 Jan. 2020
fun=@(y) y.^2-5*y+6
is the syntax you want

Kategorien

Mehr zu Desktop finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by