Splitting Cell Arrays by Delimiter
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lydia Wang
am 14 Mär. 2019
Bearbeitet: Stephen23
am 14 Mär. 2019
So I have a large data set stored in a 4699x1 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 4699x1 cell that is 3,4,1,1,2,2,2,1,1,1,4,etc...
0 Kommentare
Akzeptierte Antwort
Star Strider
am 14 Mär. 2019
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!