Effacer les filtres
Effacer les filtres

How to transpose a table of double values without the doubles getting converted to integers?

6 vues (au cours des 30 derniers jours)
I want to transpose a table, so I have used table2array() and rows2vars() functions. Both of them transpose the table but cast each double value to int64. How can I transpose it but keep the double values as they are?

Réponses (2)

Steven Lord
Steven Lord le 6 Juin 2020
That tells me your table contains both int64 and double data. When you combine the table values into one array with table2array the double data is converted to int64 as stated on this documentation page.
There's no need to convert your table into an array. Just use rows2vars on its own.
  1 commentaire
Triple G
Triple G le 8 Juin 2020
The problem is that rows2vars also casts the double data to int64. Is there a way to work around that problem?

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 8 Juin 2020
NewTable = cell2table(cellfun(@(v) {v}, table2cell(YourTable).','uniform',0))
Note that each entry will be turned into a cell. This is needed in order to preserve the appropriate datatype. So for example,
NewTable{3,1}{1}
to get at the content of what used to be Table{1,3}

Catégories

En savoir plus sur Tables 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!

Translated by