MATLAB: Cell array strings storage

cell arraysMATLAB

Two questions regarding cell arrays and strings:
1. When I enter a cell array that contains strings through the workspace, sometimes the strings appear in the cells as 'string' (with an apostrophe) and other times the strings appear as they are, without the apostrophe. I couldn't find a rule what happens when, or what is the differenece between these cases.
Is there an explanation for this?
2. When I initialize an array of strings in such a way that the strings appear in the workspace cell array with an apostrophe, and then try to access an element using array{1}, I get:
ans =
cell
'a'
to prevent the "cell" from appearing, I need to double access it (as if it is a cell inside a cell):
array{1}{1}
How can I initialize this in such a way that I can access that string directly without the double {}{}?
Thanks

Best Answer

you have to do array2{1}{1} to get that same 'a'
Yes, of course, because in the second case, you have a cell array of cell arrays of char array, not a cell array of char arrays. You get a cell array of cell arrayw because regexp can return multiple match for each cell of your orignal array. If you want to limit it to just one match (the first one if there are more than one possible), then tell regexp.
Note that your cellfun was completely unnecessary. regexp works directly with cell arrays, so instead of:
array = regexp(array, '.*', 'match'); %cellfun unnecessary
use
array = regexp(array, '.*', 'match', 'once'); %force only one output from regexp,