Azzera filtri
Azzera filtri

looping through 10 frames of 10 slots each

2 visualizzazioni (ultimi 30 giorni)
altaf ahmed
altaf ahmed il 4 Mag 2019
Commentato: altaf ahmed il 11 Mag 2019
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 Commenti
Walter Roberson
Walter Roberson il 4 Mag 2019
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 il 11 Mag 2019
yes, good catch. after removing the unneeded variable, code is much better. thanks,

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by