Reputation: 19
I'm trying to write a function that accepts a cell array of strings and builds a vector of numbers of the same length. Each item in the output vector will be the length of the strings in each cell array. If someone could please help me or show me a written example of this I would appreciate it very much. I'm new to matlab and have been working on getting this to work for a long time and cant on my own. Thank You.
Upvotes: 1
Views: 396
Reputation: 14958
A slightly more succinct version of zellus's answer:
s = {'one', 'two', 'three'};
numbers = cellfun(@length, s)
Upvotes: 2