How to access a symbolic variable created by sym?
Afficher commentaires plus anciens
Basically I need to create two sets of "y" symbolic variables that are defined by the user. Doing so with the function
u=sym('u',[y 1]);
r=sym('r',[y 1]);
After running, asking for r(1) returns r1, but asking for r1 gives the error "Undefined function or variable 'r1'.". This code is meant to end up with three matrices: u, r and K so that K*u=r, where K a numerical double symmetrical matrix. I'm assigning some values to some of the matrices so that the u matrix at the end is [0; u2; u3; u4;0] and the r is [r1;0;1000;0;r5] but I can't find a way to solve this problem. Using the function
s=solve(K*u==r,u,r)
returns the error
Error using sym.getEqnsVars>checkVariables (line 88)
The second argument must be a vector of symbolic variables.
Does anyone have any idea how to properly assign these variables and how to solve the system at the end? Thank you in advance.
2 commentaires
madhan ravi
le 19 Juil 2018
Modifié(e) : madhan ravi
le 19 Juil 2018
r=sym('r',[1 10]);
Because the vector array has to be integers?
Israel Solha
le 20 Juil 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Assumptions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!