How can I create an array from the past values in a loop?
Mostrar comentarios más antiguos
I have a loop code that gives the str a different value each time it runs but how would I combine all those string values into one?
For example my str values are 'Coco' , 'Gustavo', 'Ellen'
These are passed values of the str. So right now str would be equal to 'Ellen'.
how can I make an array that contains all of them?
Respuestas (1)
Ive J
el 25 de Oct. de 2021
something like this?
n = 10;
str = strings(n, 1);
for i = 1:n
% do whatever
str(i, 1) = gimmeMystr;
end
2 comentarios
Tatiana Kobachishvili
el 25 de Oct. de 2021
What's your goal here? If you wanna split the input string, why don't you try split?
names = ["Coco Gustavo Ellen", "hej bye now or never"];
sepnames = arrayfun(@split, names, 'uni', false);
sepnames{1}
sepnames{2}
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!