필터 지우기
필터 지우기

looping through 10 frames of 10 slots each

조회 수: 2 (최근 30일)
altaf ahmed
altaf ahmed 2019년 5월 4일
댓글: altaf ahmed 2019년 5월 11일
I am trying to loop through a frame numbered from 0 to 9 and each frame has slots numbered 0-9. Multiple loops seems to be error prone here. Any better suggestion?
Arrival_All=zeros(10,10);
for slotted_frame = 0:9
slot_index = mod(slotted_frame,slot_num);
tx_station_id = slot_index;
for slotted_num_slot = 0:9
if Arrival_All(slotted_frame+1,slot_index+1+slotted_num_slot) <= slot_init && slotted_num_slot==tx_station_id
disp('arrived packet');
end
end
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 5월 4일
WIth your test that slotted_num_slot == tx_station_id then you do not need a loop there: it is simply
if Arrival_All(slotted_frame+1,slot_idx+1+tx_station_id) <= slot_init
altaf ahmed
altaf ahmed 2019년 5월 11일
yes, good catch. after removing the unneeded variable, code is much better. thanks,

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by