Create a table from symbolic vectors
Afficher commentaires plus anciens
I would like to create a table from symbolic data. I have a vector where each component is a polynomial. I would like to have a table whose entries are these polynomials. When I use table command this happens
>> syms x1 x2 x3 x4 x5 x6
>> G=[x1, x2, x3, x4, x5, x6]
G =
[ x1, x2, x3, x4, x5, x6]
>> table(G)
ans =
G
_________
[1x6 sym]
>>
Réponses (4)
Brendan Hamm
le 26 Juin 2015
The table(var1, var2,...) function will create a table where the variables are the inputs var1, var2, ...
What you want is to have a table where each element (or column) is a variable, so use array2table:
T = array2table(G)
2 commentaires
Farid Salazar Wong
le 26 Juin 2015
Brendan Hamm
le 26 Juin 2015
It is being stored that way, just not displayed that way:
>> T.G1
ans =
x1
Azzi Abdelmalek
le 26 Juin 2015
Modifié(e) : Azzi Abdelmalek
le 26 Juin 2015
G=sym('x',[1,6])
H=num2cell(G)
table(H{:})
4 commentaires
Farid Salazar Wong
le 26 Juin 2015
Azzi Abdelmalek
le 26 Juin 2015
What are you expecting as result?
Farid Salazar Wong
le 26 Juin 2015
Walter Roberson
le 26 Juin 2015
This is a limitation on the display of tables. If you need to see the content of the columns you will need to do the formatting yourself. The table is properly formed, it just isn't displaying as you hope.
Peter Perkins
le 6 Juil 2015
0 votes
Farid, tables are meant to store "column-oriented heterogeneous data". That's not what you have, or at least not in your example. You have one symbolic variable, a 1x6 row vector. There's not much point in creating a 1x6 table, it just doesn't get you anywhere that your G variable doesn't already.
What are you really trying to achieve?
Seyed Morteza Raziee
le 22 Juin 2018
Modifié(e) : Walter Roberson
le 22 Juin 2018
x = sym('x', [6, 2]);
y = string(x);
table(y(:,1), y(:,2), 'VariableNames', {'first_column', 'second_column'})
1 commentaire
Seyed Morteza Raziee
le 25 Juin 2018
table(char(y(:,1)), char(y(:,2)), 'VariableNames', {'first_column', 'second_column'})
Catégories
En savoir plus sur Numeric Solvers 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!