Creating vector of symbols
Afficher commentaires plus anciens
For example, A = sym('A%d%d', [3 3]) generates the 3-by-3 symbolic matrix A with the elements A11, A12, ..., A33
Réponse acceptée
Plus de réponses (3)
Walter Roberson
le 4 Mar 2011
A = sym('A%d', [3 1]);
or just
A = sym('A', [3 1]);
Brian
le 4 Mar 2011
0 votes
3 commentaires
Walter Roberson
le 4 Mar 2011
Which version are you using? Those syntaxes are documented for 2010b,
http://www.mathworks.com/help/toolbox/symbolic/sym.html
Brian
le 4 Mar 2011
Walter Roberson
le 4 Mar 2011
It does appear that supplying a size is a new feature as of 2010b; the 2010a documentation does not show it.
http://www.mathworks.com/help/releases/R2010a/toolbox/symbolic/sym.html
Paulo Silva
le 4 Mar 2011
A=[3 3]; %create any numeric vector or matrix
A=sym(A) %convert it to symbolic
A=double(A) %convert it back to numeric (double in this case)
2 commentaires
Brian
le 4 Mar 2011
Paulo Silva
le 4 Mar 2011
One thing you should always have open in your matlab is the Workspace window so you can see what variables are create and their details, other ways is to do
class(A) or in the case of your small code class(ans).
In a way they can, that small code of yours gives the ans=2 but it's a symbolic response not numeric. My1=sym('1'); 2*My1 gives ans=2, again it's a symbolic value. There are other ways to make symbolic values but you should look first in your documentation.
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!