Error in defining imaginary symbolic variable in poly2sym

1 回表示 (過去 30 日間)
Arup
Arup 2020 年 2 月 25 日
回答済み: Aniket 2025 年 1 月 27 日
>> syms s;
FN1= [6,-4,-4,3,0];
FN2 = poly2sym(FN1,-1i*s);
Error using sym/poly2sym (line 27)
Second argument must be a symbolic variable.
>>
How to solve the problem?
  1 件のコメント
madhan ravi
madhan ravi 2020 年 2 月 25 日
Could you explicitly write how your expected result should look like?

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

回答 (1 件)

Aniket
Aniket 2025 年 1 月 27 日
Hi @Arup,
The error you are encountering is because the second argument of the "poly2sym" function must be a symbolic variable. The issue can be resolved by updating the code as mentioned below:
syms s;
FN1 = [6, -4, -4, 3, 0];
FN2 = poly2sym(FN1, s); % Use 's' as the symbolic variable
If you want to evaluate or manipulate the polynomial with "-1i*s", you can do that after creating the polynomial. For example:
FN2 = poly2sym(FN1, s); % Create the polynomial with 's'
FN2_at_neg_1i_s = subs(FN2, s, -1i*s); % Substitute '-1i*s' into the polynomial
This way, you first create the polynomial using "s" as the symbolic variable and then substitute "-1i*s" into the polynomial.
You can find more information regarding "poly2sym" function in this documentation: https://www.mathworks.com/help/symbolic/sym.poly2sym.html
Hope this helps!

カテゴリ

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