how to store values in while loop(inside for loop) in matrice with varying number of iterations
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear Matlab-buddies,
I have problems saving iterated values in a while loop because the while loop is inside a for loop. The for loop is used in order to perform a certain sequence for a certain number of cars. Inside the for loop, I am performing a while loop for each car, depending on speed, and until the condition in the while loop is true I would like to save each speed for each car. The problem here is that the number of iterations vary depending on car. My code works when only applying the code on one car- it looks like this:
myCoordList=[]
for b = 1: Ant_car %code performed for a certain number of cars
XXXX(not important code)
k=1;
while true
T_Guess(b)=T_Guess+Diff/10
myCoordList(end+1,:)=[T_Guess] %unique number of iterations for each car and this needs to be saved somehow
end
end
Thank you!
1 Kommentar
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!