How can I convert table of chars to array of strings?
Mostra commenti meno recenti
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 Commenti
madhan ravi
il 7 Ago 2019
Share the code that you use to create a table.
David K.
il 7 Ago 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
il 7 Ago 2019
omar khater
il 7 Ago 2019
Guillaume
il 7 Ago 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
il 7 Ago 2019
Modificato: omar khater
il 7 Ago 2019
Risposta accettata
Più risposte (2)
Azzi Abdelmalek
il 7 Ago 2019
0 voti
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)))
Azzi Abdelmalek
il 7 Ago 2019
Modificato: Azzi Abdelmalek
il 7 Ago 2019
0 voti
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)
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!