string from a textbox

3 views (last 30 days)
abdullah ek
abdullah ek on 4 Jul 2018
Commented: Paolo on 5 Jul 2018
hi. i want to extract 4,5,6,5 from string 4x^3 + 5x^2 + 6x^1 + 5

Answers (2)

Paolo on 4 Jul 2018
Edited: Paolo on 4 Jul 2018
str = '4x^3 + 5x^2 + 6x^1 + 5'
num = regexp(str,'(?<!\^)(\d)','match');
Paolo on 5 Jul 2018
What missing coefficients? I don't see any for the equation you shared. Perhaps you need to use str2sym to convert the string to a symbolic expression before you can use sym2pol or coeffs as suggested by Stephen. I am unable to test it for you because of this bug.

Sign in to comment.

Stephen23 on 5 Jul 2018
Edited: Stephen23 on 5 Jul 2018
If you are using symbolic toolbox then you could use the appropriate function:





Community Treasure Hunt

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

Start Hunting!