Change data type of a row in a table?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Daniel Broadie
el 6 de Jun. de 2018
Editada: Walter Roberson
el 6 de Jun. de 2018
Ex. Change this table
1 2 3 4
2 1 3 2
to
'1' '2' '3' '4'
2 1 3 2
0 comentarios
Respuesta aceptada
Walter Roberson
el 6 de Jun. de 2018
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 comentarios
Walter Roberson
el 6 de Jun. de 2018
Editada: Walter Roberson
el 6 de Jun. de 2018
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]
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!