How can I convert table of chars to array of strings?
Show older comments
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 Comments
madhan ravi
on 7 Aug 2019
Share the code that you use to create a table.
David K.
on 7 Aug 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
on 7 Aug 2019
omar khater
on 7 Aug 2019
Guillaume
on 7 Aug 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
on 7 Aug 2019
Edited: omar khater
on 7 Aug 2019
Accepted Answer
More Answers (2)
Azzi Abdelmalek
on 7 Aug 2019
0 votes
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 Comment
omar khater
on 7 Aug 2019
Azzi Abdelmalek
on 7 Aug 2019
Edited: Azzi Abdelmalek
on 7 Aug 2019
0 votes
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 Comment
omar khater
on 7 Aug 2019
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!