Why sym2poly function converts a random string to s polynomial?
古いコメントを表示
Why sym2poly function converts a random string ('cacssd' for example) to [1 0] polynomial?
syms s
rt='cacd';
num=sym(rt);
snum=sym2poly(num)
I want to handle an error for this but unfortunatly there is no error. Any idea?
採用された回答
その他の回答 (1 件)
Paulo Silva
2011 年 5 月 29 日
1 投票
The result [1 0] means that there's a symbolic variable with 1 for it's coefficient, the polynomial is:
1*cacd+0
6 件のコメント
sadel
2011 年 5 月 29 日
Paulo Silva
2011 年 5 月 29 日
that's a wrong assumption, syms s just defines s as symbolic, the next lines of code have nothing to do with the first, in the third line you define the string inside the variable rt as symbolic and store it in the variable num, it's the symbolic variable num contents that are converted.
Oleg Komarov
2011 年 5 月 29 日
Yes but you declare sym(rt) which is sym('cacd')
sadel
2011 年 5 月 29 日
Paulo Silva
2011 年 5 月 30 日
symvar
ismember
Walter Roberson
2011 年 5 月 30 日
casd *does* have "the type of a polynomial", just as much as 1*x+0 does.
Perhaps what you want is to restrict to certain variables and then use coeff() or coeffs() to detect whether those variables occur.
カテゴリ
ヘルプ センター および File Exchange で Operations on Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!