Creating an ordered list of vectors
Afficher commentaires plus anciens
I'm looking to create a list of vectors arbitrary in length. I was looking for something along the lines of: iterations=___ % some arbitrary number
for i=1:iterations vi=[1 2 3 4]; end
Hoping this would create the vectors v1, v2, v3, v4 ... which are all the same vector [1 2 3 4].
Réponse acceptée
Plus de réponses (2)
Jan
le 31 Mai 2011
Use a CELL instead:
v = cell(1, iterations);
v(:) = {1:4}
Now you can use v{1} instead of v1. It is always better (nicer, safer, faster) to use an index as index, instead of hiding the index in the name of the variable.
Paulo Silva
le 31 Mai 2011
1 vote
v=perms(1:4);
Now instead of having v1,v2... you have v(1),v(2)...
1 commentaire
Jan
le 31 Mai 2011
Why PERMS? The OP looks for v1=[1,2,3,4] etc.
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!