Error using symbolic function inside a matlab functions
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lorenzo Lunghini
le 21 Déc 2021
Commenté : Lorenzo Lunghini
le 21 Déc 2021
Hi, i'm trying to make a function that calculate symbolic expression and after that it make a surface plot. Doing this:
syms r
alpha(r)=alpha0+pi/(tf)*(t-t0-(r-r0)/vr) %alpha0, tf, t, r0, vr are defined and constant
All work and no errors are given back.
Problems comes out when i wrote the same rows of code inside a matlab function, matlab gives back this error:
"Error using * (line xx) Invalid operand. Variables of type "sym" cannot be combined with other models."
I'm trying to run this code on server because of the quantity of calculation, on server the version of matlab installed is Matlab2018b, when i run the same files on local (matlab2021b) all work as well.
It is possible that from version 2018b to 2021 the methods to perform operations between "sym" and "double" objects are changed?
2 commentaires
Réponse acceptée
Walter Roberson
le 21 Déc 2021
You are trying to use a symbolic function in combination with the Control System Toolbox. That is not possible.
In some cases, you can convert the symbolic function to a ratio of two polynomials and then extract the numerator and denominator and build transfer functions. Or sometimes you can convert to state-space representation.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!