recognize function from string
조회 수: 6 (최근 30일)
이전 댓글 표시
Is there a way in Matlab to recognize the variables and parametest of function from sting. For example I have a string: "a1*x+a2*x^2+y", and necessary to get a function where a1,a2 - constants and x, y - variables.
댓글 수: 0
채택된 답변
Star Strider
2017년 3월 25일
Not that I am aware of.
The closest you can get to what you want to do (in this example of a polynomial) is the Symbolic Math Toolbox coeffs function, and even then you have tell it what the variables are:
syms a1 a2 x y
z = a1*x+a2*x^2+y;
[coefficients,variables] = coeffs(z, [x y])
coefficients =
[ a2, a1, 1]
variables =
[ x^2, x, y]
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!