MATLAB: What is the difference between string arrays and cell arrays of character vectors

double-quotesMATLABstring arrays

R2016b allows you to create string arrays, and R2017A allows you to use the double-quote syntax for specifying string literals. What is the practical difference between a string array (e.g ["one", "two"]) and a cell array of character vectors (e.g. {'one', 'two'}). Aside from minor conveniences like "strlength" (which could easily have been implemented to operate on cell arrays of character vectors), why should I care about this? Am I missing something?

Best Answer

I'd like to add that for loops can become cleaner, instead of cellarray{idx} you can use idx directly. E.g. when displaying messages or iterating over struct fields.
for field = string(fieldnames(S)')
S.(field) = somevalue;
end
% I haven't figured out why this only works with horizontal arrays
In addition, cellfun typically requires the annoying argument 'UniformOutput' flag to be false when a function returns a character array. If a function that returns a char array is changed to return a scalar string this would clean things up too, e.g.:
[~, patientID] = cellfun(@fileparts,{cohort.pfolder})
%no need for UniformOutput if fileparts() is modernized to return strings.