Error in App Designer " Undefined function 'sym2poly' for input arguments of type 'char'.."
3 次查看(过去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609830/image.png)
And this is what I have entered in my GUI
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609835/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609840/image.png)
And here is what my GUI looks like at this revision of code after clicking "Calculate". (No User-defined Inputs for numerator and denominator)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609845/image.png)
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.
0 个评论
采纳的回答
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))
den = str2sym(string(s^3+5*s^2-10*s-5))
numMatrix = sym2poly(num)
denMatrix = sym2poly(den)
forwardTransfer = tf(numMatrix, denMatrix)
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!