string from a textbox

조회 수: 1 (최근 30일)
abdullah ek
abdullah ek 2018년 7월 4일
댓글: Paolo 2018년 7월 5일
hi. i want to extract 4,5,6,5 from string 4x^3 + 5x^2 + 6x^1 + 5

답변 (2개)

Paolo
Paolo 2018년 7월 4일
편집: Paolo 2018년 7월 4일
str = '4x^3 + 5x^2 + 6x^1 + 5'
num = regexp(str,'(?<!\^)(\d)','match');
  댓글 수: 2
abdullah ek
abdullah ek 2018년 7월 5일
i also want to extract the missing cofficients i am using the function sym2pol like syms x c = sym2poly(x^3 - 2*x - 5); but i dont know how to convert my value from textbox into symbolic polynomial which can be placed in sym2poly function.
Paolo
Paolo 2018년 7월 5일
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.

댓글을 달려면 로그인하십시오.


Stephen23
Stephen23 2018년 7월 5일
편집: Stephen23 2018년 7월 5일
If you are using symbolic toolbox then you could use the appropriate function:

태그

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by