Hi,
Why are strings stored in an extra cell when placed in a table so that one has to add an extra {1} to access the string? I run into this issue, e.g., when importing data tables with strings using the 'ImportData' interface. Small example (not using the importing function):
x = {'FirstString' 'SecondString' ''};
xTable = cell2table(x);
out1 = class(xTable)
out2 = class(xTable(1,1))
out3 = class(xTable{1,1})
out1 =
table
out2 =
table
out3 =
cell
out1 and out2 make sense. But why is out3 = cell? Why not 'char'? E.g., if I want to find out that the 3rd string is empty, I have to do this:
out4 = isempty(xTable{1,3}{1})
which, I feel, is rather impractical.
What is the reason for this design? Or do I do something wrong and I can directly place strings into a table? Thank you for your help!
Best Answer