-1

(5/(r^2*9))- ((2)/(9*(6-r)^2)) - r = 0

would like to solve the above polynomial in matlab:

fun= (5/(r^2*9))- ((2)/(9*(6-r)^2))-r;
x0 = 10; % some initial point
x = fsolve(fun,x0)

Not working! Error: Undefined operator '.^' for input arguments of type 'function_handle'.

Mixter
  • 193
  • 9
  • 1
    In your post, `r` is undefined, `fun` is not defined as an anoymous function and `.^` isn't used anywhere. The error message has nothing to do with the code that you have posted. Please create a [mcve] – Sardar Usama Dec 14 '19 at 19:59
  • Thanks @Thales for the clarification – Mixter Dec 14 '19 at 20:26

1 Answers1

2

Just create the function handle and properly vectorize the function and it should work:

fun= @(r) (5./(r.^2*9))- ((2)./(9*(6-r).^2))-r;
x0 = 1; % some initial point (10 is not a good initial estimate)
x = fsolve(fun,x0)
Thales
  • 1,181
  • 9
  • 10