フィルターのクリア

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

6 ビュー (過去 30 日間)
Triple G
Triple G 2020 年 6 月 6 日
回答済み: Walter Roberson 2020 年 6 月 8 日
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?

回答 (2 件)

Steven Lord
Steven Lord 2020 年 6 月 6 日
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 件のコメント
Triple G
Triple G 2020 年 6 月 8 日
The problem is that rows2vars also casts the double data to int64. Is there a way to work around that problem?

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 6 月 8 日
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}

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by