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
per isakson
2020년 12월 20일
편집: per isakson
2020년 12월 20일
"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.
답변 (1개)
Cris LaPierre
2020년 12월 18일
0 개 추천
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
Cris LaPierre
2020년 12월 19일
Stephen23
2020년 12월 20일
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.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!