How does one store all the words from a loop into a variable?
Mostrar comentarios más antiguos
for j = 1:length(wordsB)
PositionB = Shuffle2 (j); % Use number from the random array
% wordsB (PositionB); % Assign random position to words in text file
RandomWordsB = wordsB(PositionB);
% RandomWordsB = wordsB(PositionB); %Assign the obtained list to a varible to be displayed
disp (RandomWordsB) %display the random word list
end
RandomWords = [RandomWordsA; RandomWordsB]; %combining words from both arrays
disp (RandomWords) %display the random word lists
2 comentarios
Image Analyst
el 14 de Dic. de 2018
It would have been easier for people to help you if you had attached the text files.
Adam Danz
el 14 de Dic. de 2018
...or at least format the code using alt+enter.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 15 de Dic. de 2018
RandomWordsA(i) = wordsA(PositionA); %Assign the obtained list to a varible to be displayed
and
RandomWordsB(j) = wordsB(PositionB);
We cannot tell what datatype you are working with, but I suspect that to get the 12 x 2 array that you want, you will need to change
RandomWords = [RandomWordsA; RandomWordsB]; %combining words from both arrays
to
RandomWords = [RandomWordsA(:), RandomWordsB(:)]; %combining words from both arrays
1 comentario
Ynvl Nhm
el 15 de Dic. de 2018
Categorías
Más información sobre Loops and Conditional Statements 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!