fill up a cell array with string elements
17 views (last 30 days)
Show older comments
Hye
I have to write a function that puts the words of a string in a cell array.
I've made the following script.
I already get a cell array with the right amount of cells, but they are all filled up with the first word of the string.
How do I get this right?
function [words] = giveWords(sentence)
k = split(sentence);
words = cell(1,length(k));
words(1,:) = k(1,:);
end
0 Comments
Answers (2)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!