Error in App Designer " Undefined function 'sym2poly' for input arguments of type 'char'.."

5 次查看(过去 30 天)
Hello. I want to build an application that lets the user input the numerator and the denominator of a transfer function and the code will output the plots for the step response, nyquist, pzmap, and bode. It also calculates the overall transfer function setted in a unity feedback.
The problem is that this error "Undefined function 'sym2poly' for input arguments of type 'char'." pops up and hinders the calculation when I try to run and put inputs for my Edit Text Fields for the numerator and denominator.
Here is my code
And this is what I have entered in my GUI
I tried to remove the association of the givenNum to app.EnterNumeratorEditField.Value , and givenDen to app.EnterDenominatorEditField.Value and replaced actual polynomials to the variable strings in the code itself. By doing this, the error was removed and it calculated an output for the overall transfer function.
And here is what my GUI looks like at this revision of code after clicking "Calculate". (No User-defined Inputs for numerator and denominator)
But i need to make use of a USER-DEFINED numerator and denominator for the graphical input field. And I think that error really is the only thing that stops the program and I honestly don't know how to fix it.
Thank you in advance.

采纳的回答

Star Strider
Star Strider 2021-5-6
Apart from the app code, apparently the numerator and denominator polynomials are not being transofmred into symbolic variables.
Try something like this —
syms s
num = str2sym(string(s^2+2*s+1))
num = 
den = str2sym(string(s^3+5*s^2-10*s-5))
den = 
numMatrix = sym2poly(num)
numMatrix = 1×3
1 2 1
denMatrix = sym2poly(den)
denMatrix = 1×4
1 5 -10 -5
forwardTransfer = tf(numMatrix, denMatrix)
forwardTransfer = s^2 + 2 s + 1 ---------------------- s^3 + 5 s^2 - 10 s - 5 Continuous-time transfer function.
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by