Why sym2poly function converts a random string to s polynomial?
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
sadel
2011년 5월 30일
댓글 수: 6
Walter Roberson
2011년 5월 30일
If that's what you wanted, they just use
if ismember('s',symvar(insertfunction))
snum = sym2poly(sym(insertfunction));
else
warn='Invalid variable'
end
However, the presence of s as a free variable in insertfunction does not establish that insertfunction codes a polynomial.
추가 답변 (1개)
Paulo Silva
2011년 5월 29일
The result [1 0] means that there's a symbolic variable with 1 for it's coefficient, the polynomial is:
1*cacd+0
댓글 수: 6
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!