Looping to create multiple variables?

I would like to run the following code 50 times, each time saving the output into a new variable (eg. s1, s2, s3,...,s50)
s = [reshape(randperm(32),[],1),randi(8,32,1)];
How would I do that?
Thank you! (sorry if this is a very trivial question, I'm new)

2 comentarios

Adam
Adam el 13 de Oct. de 2017
You should never want 50 variables in your workspace when 1 would do!
Amos Tan
Amos Tan el 14 de Oct. de 2017
thank you for the advice! (:

Iniciar sesión para comentar.

 Respuesta aceptada

KL
KL el 13 de Oct. de 2017
Editada: KL el 13 de Oct. de 2017
Don't create such variables, read here to know why
instead, do something like this,
for k = 1:50
s(:,:,k) = [reshape(randperm(32),[],1),randi(8,32,1)];
end

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 13 de Oct. de 2017

Comentada:

el 14 de Oct. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by