Demo entry 6762919

hw5

   

Submitted by anonymous on Oct 17, 2018 at 20:58
Language: Matlab. Code size: 391 Bytes.

function x = aloha_simulation(J,p,lambda,N)
    x=zeros(J,N);
    for t=1:N-1
        arrivals=binornd(1,lambda,J,1);
        packets=x(:,t)>0;
        transmit=binornd(1,p,J,1);
        service = packets & transmit & ~arrivals;
        if sum(service)<=1
            x(:,t+1)=x(:,t)+arrivals-service;
        else
            x(:,t+1)=x(:,t)+arrivals;
        end
    end
end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).