How to create a vector to store my values

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 comentario

per isakson
per isakson el 20 de Dic. de 2020
Editada: per isakson el 20 de Dic. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 18 de Dic. de 2020

0 votos

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 comentarios

Cris LaPierre
Cris LaPierre el 19 de Dic. de 2020
You just need some more experience with indexing. I'd suggest Ch 5 and Ch 13 of MATLAB Onramp.
Stephen23
Stephen23 el 20 de Dic. de 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.

Iniciar sesión para comentar.

Categorías

Productos

Versión

R2015b

Etiquetas

Preguntada:

el 18 de Dic. de 2020

Editada:

el 20 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by