【问题标题】:fsolve a polynomial in matlab not working [closed]fsolve matlab中的多项式不起作用[关闭]
【发布时间】:2019-12-14 19:55:02
【问题描述】:

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

想在matlab中求解上述多项式:

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

不工作! 错误:“function_handle”类型的输入参数的未定义运算符“.^”。

【问题讨论】:

  • 在您的帖子中,r 未定义,fun 未定义为匿名函数,.^ 未在任何地方使用。该错误消息与您发布的代码无关。请创建一个minimal reproducible example
  • 感谢@Thales 的澄清

标签: matlab math polynomial-approximations


【解决方案1】:

只需创建function handle 和正确的vectorize 函数,它应该可以工作:

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 2021-01-10
    相关资源
    最近更新 更多