Stacking in a loop

조회 수: 10 (최근 30일)
Nik Rocky
Nik Rocky 2020년 6월 26일
댓글: dpb 2021년 8월 10일
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
dpb
dpb 2021년 8월 10일
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...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by