how to store values in while loop(inside for loop) in matrice with varying number of iterations

1 vue (au cours des 30 derniers jours)
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!

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by