How do I get matlab to create a new cell array of varying length with every iteration of a for loop?
Show older comments
In this loop, FilterList is an existing cell array that contains words of a certain length, and wordLength is an input previously specified by the user.
NextGuess = 'e';
H = 1;
for j = 1:wordLength
for i = 1:length(FilterList)
if NextGuess == FilterList{i}(j)
NewList(H) = {FilterList{i}};
H = H+1;
end
end
end
I am trying to create a new cell array with every iteration, but instead it is grouping the results from all the iterations into NewList.
1 Comment
Thorsten
on 29 Apr 2015
It would be helpful if you give some sample data and explain what's the purpose of your code. Maybe there is a better way to do it.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!