How can I convert table of chars to array of strings?
Mostrar comentarios más antiguos
Hello,
I have table variable (Input_table) like this
''1'' ''8'' ''2'' ''5'' '1' '1' ''Z'' ''F'' ''1'' ''3'' ''C'' ''5'' ''Y'' ''U'' ''4'' ''Q'' ''3''
''4'' ''4'' ''0'' ''9'' '1' '8' ''B'' ''R'' ''1'' ''2'' ''E'' ''8'' ''1'' ''Z'' ''1'' ''N'' ''X''
I want to convert every row into one string so the output to be array of 2 rows
'182511ZF13C5YU4Q3'
'440918BR12E81Z1NX'
I have tried
join(char(table2cell(Input_table))
but I get the error
Error using char
Cell elements must be character arrays.
6 comentarios
madhan ravi
el 7 de Ag. de 2019
Share the code that you use to create a table.
David K.
el 7 de Ag. de 2019
Without that, I have a shot in the dark that
answer = cellfun(@char, table2cell(Input_table));
will work for what you want.
omar khater
el 7 de Ag. de 2019
omar khater
el 7 de Ag. de 2019
Guillaume
el 7 de Ag. de 2019
Can you use valid matlab syntax to show how to create an example of your table, or attach your table as a mat file. Right now, it's very unclear how the data is stored in your table.
Perhaps, you should also explain how the table was created in the first place.
omar khater
el 7 de Ag. de 2019
Editada: omar khater
el 7 de Ag. de 2019
Respuesta aceptada
Más respuestas (2)
Azzi Abdelmalek
el 7 de Ag. de 2019
0 votos
s={'1' '8' '2' '5' '1' '1' 'Z' 'F' '1' '3' 'C' '5' 'Y' 'U' '4' 'Q' '3'
'4' '4' '0' '9' '1' '8' 'B' 'R' '1' '2' 'E' '8' '1' 'Z' '1' 'N' 'X' }
a=cellstr(reshape([s{:}],size(s)))
1 comentario
omar khater
el 7 de Ag. de 2019
Azzi Abdelmalek
el 7 de Ag. de 2019
Editada: Azzi Abdelmalek
el 7 de Ag. de 2019
0 votos
s={'1' '8' '2' '5' '1' '1' 'Z' 'F' '1' '3' 'C' '5' 'Y' 'U' '4' 'Q' '3'
'4' '4' '0' '9' '1' '8' 'B' 'R' '1' '2' 'E' '8' '1' 'Z' '1' 'N' 'X' }
a=join(s,2)
You can add a delimiter
a=join(s,'',2)
1 comentario
omar khater
el 7 de Ag. de 2019
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!