Change data type of a row in a table?

조회 수: 4 (최근 30일)
Daniel Broadie
Daniel Broadie 2018년 6월 6일
편집: Walter Roberson 2018년 6월 6일
Ex. Change this table
1 2 3 4
2 1 3 2
to
'1' '2' '3' '4'
2 1 3 2

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 6일
No, that is no possible. In a table() object, all elements of a column must be the same data type.
In order for some entries in a column to be character vectors and some entries to be numeric, you would have to change the column to cell array, ending up with
['1'] ['2'] ['3'] ['4']
[ 2] [ 1] [ 3] [ 2]
  댓글 수: 2
Daniel Broadie
Daniel Broadie 2018년 6월 6일
What about in a cell array?
Walter Roberson
Walter Roberson 2018년 6월 6일
편집: Walter Roberson 2018년 6월 6일
Each cell array entry can be a different data type.
A = [ 1 2 3 4
2 1 3 2 ]
B = num2cell(A);
B(1,:) = sprintfc('%d', A(1,:));
disp(B)
'1' '2' '3' '4'
[2] [1] [3] [2]

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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