How to access a symbolic variable created by sym?
Show older comments
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 Comments
madhan ravi
on 19 Jul 2018
Edited: madhan ravi
on 19 Jul 2018
r=sym('r',[1 10]);
Because the vector array has to be integers?
Israel Solha
on 20 Jul 2018
Accepted Answer
More Answers (0)
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!