Cell in table data type conversion
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mehdi Jaiem
el 4 de Mayo de 2022
Comentada: Walter Roberson
el 4 de Mayo de 2022
Greetings Suppose I have column of type table and the content of the cells has "yes" and "no". Instead I wand the content of the cells to be true or false with main class as boolean (not string or char). Furthermore i have to use cellfunc() to modify the column (cells)content. Using strcmp or replace is not what I seek here. Instead i want as mentioned to have a class type boolean.
0 comentarios
Respuesta aceptada
Chunru
el 4 de Mayo de 2022
a = (1:3)';
b = {'yes', 'no', 'yes'}';
t = table(a,b)
t.b = categorical(t.b)=='yes'
0 comentarios
Más respuestas (1)
Walter Roberson
el 4 de Mayo de 2022
a = (1:3)';
b = {'yes', 'no', 'yes'}';
t = table(a,b)
t.b = cellfun(@(b) length(b) == 3, t.b)
2 comentarios
Walter Roberson
el 4 de Mayo de 2022
data78 ={
'[100019, 100003, 100005, 100016, 100007]'
'[100017]'
'[100001, 100012]'
'[100012]'
}
try1 = cellfun(@str2num, data78, 'uniform', false)
try2 = cellfun(@str2double, regexp(data78, '\d+', 'match'), 'uniform', 0)
Ver también
Categorías
Más información sobre Data Type Conversion 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!