MATLAB Answers

How do I fix this code? It says "Conversion to function_handle is not possible" on the line f(×) = (x^4) - (10*x^3) + 5

45 views (last 30 days)
Ar Clique
Ar Clique on 20 Jan 2021
Commented: Star Strider on 20 Jan 2021
xo = 1; dx = xo; dx = 0.00001; f(x) = (x^4) - (10*x^3) + 5;
P = 1; While P < 0; x1 = x; if f(x1) = 0; exactroot = 0; x2 = x1; P = 0; else x2 = x1 + dx; P = f(x1)*f(x2); x = x2; end end
x1 = a; x2 = b

Answers (1)

Star Strider
Star Strider on 20 Jan 2021
First, fix the typographical errors. Remember that MATLAB is case-sensitive.
Second, see the documentation section on Anonymous Functions.

  5 Comments

Show 2 older comments
Star Strider
Star Strider on 20 Jan 2021
My pleasure!
Function handles are important in MATLAB. See What Is a Function Handle? for an extended discussion.
For an introduction to MATLAB see Getting Started. Also see Learn with MATLAB and Simulink Tutorials.
Remember that none of us (well, at least most of us) were not born knowing how to program computers in any programming language!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!