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

2 views (last 30 days)
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!

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!