How to take a function_handle's coefficients

5 ビュー (過去 30 日間)
Sam
Sam 2017 年 11 月 15 日
コメント済み: Jan 2017 年 11 月 15 日
I don't think it's too complex but I can't see a solution anywhere.
I have a function_handle f =@(y) (y^3 -5) which clearly has coefficients [1 0 0 -5] but I do not know what I need to write to be able to extract it from function_handle.
i.e. q = [(coefficients extracted)]
I want to be able to take this because then i can work out the roots of the polynomial straight from roots(q) where q is the row vector of coefficients of the function handle.
Is anyone able to help, I would really appreciate it.
  1 件のコメント
Jan
Jan 2017 年 11 月 15 日
This might not be trivial. What do you expect for:
f = @(y) sin(y)
? Is the function guaranteed to be a polynomial? Then why not defining it as [1,0,0,-5] directly?

サインインしてコメントする。

採用された回答

M
M 2017 年 11 月 15 日
syms y
q=sym2poly(f(y))
q =
1 0 0 -5

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by