For loop help!
Afficher commentaires plus anciens
I need helpt with a for loop to pick numbers from a vector and put them in an existing non square in the order shown in the figure below (hop it makes sense). It starts at the dot and then follow the arrow. the resulting matrix should be as the one in the blackbackgrownd figure.
Sorry if this has been asked before <3 .
Thank you.

6 commentaires
James Tursa
le 18 Nov 2020
Is this just for the specific problem you show (in which case you can simply use explicit indexing since the problem is small enough)? Or is there really a bigger problem you are trying to solve?
BiaoZhun
le 18 Nov 2020
James Tursa
le 18 Nov 2020
Well, you don't necessarily need a for-loop. We just need to know the explicit indexing rule for your large vector.
BiaoZhun
le 18 Nov 2020
James Tursa
le 18 Nov 2020
Start with 3 and increment by 3's, then start with 2 and increment by 3's, then start with 1 and increment by 3's?
BiaoZhun
le 18 Nov 2020
Réponses (1)
"... so becase of the amount of data i need a for loop"
I doubt that using a loop would be a good approach.
V = 1:12;
R = 3;
M = flipud(reshape(V,R,[]))
Your larger vector:
V = rand(118668,1);
R = 9889;
M = flipud(reshape(V,R,[]));
size(M)
Catégories
En savoir plus sur Loops and Conditional Statements 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!