Stacking in a loop

4 visualizaciones (últimos 30 días)
Nik Rocky
Nik Rocky el 26 de Jun. de 2020
Comentada: dpb el 10 de Ag. de 2021
Hello,
Every time I get stacked in for loop. Its happens just with one Dataset. The similar datasets (Traj_inerpl) working good.
I have one loop:
for traj_cnt = 1:length(Traj_interpl) %for every Traj-Cell
for t_row_cnt = 1:length(Traj_interpl{traj_cnt}) %for any row of Traj %%% I'm stacking here <<<<<<<<
if t_ref(t_ref_cnt) == Traj_interpl{traj_cnt}(t_row_cnt,1) %if right row of Traj is choosen
motorspeed_detected(traj_cnt) = Traj_interpl{traj_cnt}(t_row_cnt,2); %write detected value to array
break; %just one motorspeed_detected value is possible/no sence to follow a searching
else %%% If I do a pause I stay be here
motorspeed_detected(traj_cnt) = 0;
end
end
end
Within I create a motorspeed_detected array. I stay stacking while second for-loop. If I make a pause while stacking — program stay on else expression (not inside). When I left a pause — program starts running and work.
Variables on time of stacking:
t_ref_cnt = 1602 %Outside loop cnt
traj_cnt = 51 %every time different values
length(Traj_interpl) = 203
t_row_cnt = 115 %every time different values
length(Traj_interpl{traj_cnt}) = 119 %every time different values
t_ref(t_ref_cnt) = 17.7600 %every time different values
Traj_interpl{traj_cnt}(t_row_cnt,1) = 7.8300 %every time different values
motorspeed_detected(traj_cnt) = 0
What can be a reason?
Thank you!
  1 comentario
dpb
dpb el 10 de Ag. de 2021
By " I get stacked in for loop" do you mean "stuck", maybe?
And it is not at all clear what pause has to do with anything -- certainly if you enter a pause command, MATLAB will indeed "pause temporarily stops MATLAB® execution and waits for the user to press any key" so where you are would all depend on when such was issued.
That it would be random values each time is to be expected; there would be no way to synchronize that command timing with the time the loop began.
If instead you mean there's one file for which you don't ever satisfy the if condition; that would be purely data dependent -- that there simply isn't any value for that file that is True.
We could only verify that by having the data file...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by