How to create a vector to store my values
Afficher commentaires plus anciens
Hello all,
I have this for loop shown below which prints for every Iteration what you can see right in the following picture. What I wanna do and dont know how, is to take all these Routes for every Iteration and store it in a vector [1 x m ], so that in the end of the execution the final vector would have all those routes inside. Could anyone help me by providing me that extra line of code in my already existing code? Probabbly all that it needs is to add 1 more loop outside that one but I dont know how to form it correctly.
Thank you very much
my code:

the results:

To make my answer more accurate, I need a vector which according to the shown result would be something like
p = [ 1 5 9 10 2 22 23 1 14 4 11 24 15 1 13 21 12 3 7 1 8 6 19 26 1 20 16 25 17 1]
Thanks in advance!
1 commentaire
per isakson
le 20 Déc 2020
Modifié(e) : per isakson
le 20 Déc 2020
"provide me with a code line that could generate the vector" More than one line is required.
Your chance to get a detailed answer increases if you provide your code as text and format it with
. Select the text and click the button.
Réponses (1)
Cris LaPierre
le 18 Déc 2020
0 votes
In you incorporate indexing into your assignment statement, you can tell MATLAB where to store each result. See the example "Assign Matrix Values" on the for-loop documentation page.
2 commentaires
Cris LaPierre
le 19 Déc 2020
Stephen23
le 20 Déc 2020
John Smith's "Answer" moved here:
I have tried a couple of things in the process of making a way to solve my problem, but unfortunatelly it seems that none of them worked in the end.. My coding skills might be still poor for such a task, so if anyone could provide me with a code line that could generate the vector Ι need (that would store inside all the generating routes), Ι'd be really grateful.
Catégories
En savoir plus sur Matrix Indexing 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!