for loop inside for loop

1 Ansicht (letzte 30 Tage)
talal alqahtani
talal alqahtani am 20 Jan. 2020
Kommentiert: talal alqahtani am 20 Jan. 2020
So I have this vector of number of packets start from 1:1e3 . each single packet have random number of datagrams and each of this datagrams have a size following geometeric distribution. The idea is to find the total size of all datagrams within each packet and for all the packets (from 1:1e3). So I did this code that have 1e3 packets and each packet have a random number of datagrams. but, once I tried to find the total size of all datagrams for all the packets, it only gives me the first total size of packet number 1 then stop. here is my code:
xi=0.91; sigma=74.1; mu=81.5; nof_packets=1000;
p=25;
mean=1/p;
for q=1:nof_packets
n_d(q)=geornd(mean);
for m=1:n_d
datagram_size(m)=gprnd(xi,sigma,mu);
counter=sum(datagram_size);
end
end
  5 Kommentare
Sindar
Sindar am 20 Jan. 2020
Does my code work for you?
talal alqahtani
talal alqahtani am 20 Jan. 2020
it works perfect. Thank you

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by