MATLAB: If i have a for loop doing iterations based on random intervals of time between .5-5 seconds, how do i keep track of that time for loops for i=1:60; x=(.5+4.5*rand)+x; how do i figure out how much time went by during these 60 iterations? Best Answer x = cumsum(.5+4.5*rand(60,1));or justx = sum(.5+4.5*rand(60,1)); Related SolutionsMATLAB: How to generate just one random number in every iteration of for loop I think you wantif x(i) < 0.01 && y(i) < 0.5instead ofif x<0.01 && y<0.5 MATLAB: How to overcome an invalid use of operator error for i = 1:60 F=99000.*rand(60,1)+1000; P=999000.*rand(60,1)+1000; T=4990.*rand(60,1)+10; r=0.04.*rand(60,1)+0.05; t=0.0008.*rand(60,1)+0.0001; pop = [F P T r t]end Related QuestionHow to add a value in ONE element of a matrix in a for loopRepeat for loop until condition is met.Moving average of unevenly spaced time dataUsing boolean matrix to govern While loop
Best Answer