필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by