MATLAB: Splitting Cell Arrays by Delimiter

cell arrays

So I have a large data set stored in a 4699×1 cell. Each row has a different number of string items separate by commas. Is there any way to count how many items there are in each row? For example, with these rows, I would like a 4699×1 cell that is 3,4,1,1,2,2,2,1,1,1,4,etc…Screen Shot 2019-03-14 at 5.37.53 PM.png

Best Answer

Try this:
s = {'qwerty,uiop'; 'asdf,ghjkl,zxcvb'};
for k1 = 1:size(s,1)
r(k1) = numel(strsplit(s{k1}, ','));
end
Out = r % View Results (Delete)
producing:
Out =
2 3
Experiment to get the result you want.