I have a string describing a polynomial and would like to extract its coefficients
I'm currently using the following code:
p = 'x^8 + x^4 + x^3 + x^2 + 1';
c = coeffs(sym(p), 'all');
which gives the expected output
c = [1, 0, 0, 0, 1, 1, 1, 0, 1]
however using sym in this way raises the warning: Support of strings that are not valid variable names or define a number will be removed in a future release. To create symbolic expressions, first create symbolic variables and then use operations on them.
I can supress this warning but would like to find an alternative that won't be deprecated in the future. What other approaches are available?
Isn't it simply by declaring at the beginning of your code : syms p instead of giving to Matlab a "last minute discovery" when you use sym(p), making it nervous and reacting in this way ?