No BSD License  

Highlights from
Home Networking Basis

Home Networking Basis

by

 

11 Aug 2003 (Updated )

M-files for chapters 2-10 and Simulink models for Ethernet and Wireless Ethernet.

TXmask.m
%calculating PSD
x=ceil(rand(256,256)*2-1);
t4b5b=[1 1 1 1 0
0 1 0 0 1    
1 0 1 0 0    
1 0 1 0 1    
0 1 0 1 0    
0 1 0 1 1    
0 1 1 1 0    
0 1 1 1 1    
1 0 0 1 0    
1 0 0 1 1
1 0 1 1 0
1 0 1 1 1
1 1 0 1 0
1 1 0 1 1
1 1 1 0 0
1 1 1 0 1];
pspc=zeros(1,2048);
for i=1:256
    %4b5b encoding
    for j=1:4:256
        xin=x(i,j:j+3);
        xind=xin(1)*8+xin(2)*4+xin(3)*2+xin(4)+1;
        xout=t4b5b(xind,:);
        jj=1+(j-1)/4*5;
        y(jj:jj+4)=xout;
    end
    xlin=zeros(1,321);
    slv=0;
    %MLT3 encoding
    for j=1:320
        if y(j)==1
            if slv==0
                xlin(j+1)=xlin(j)+1;
                if xlin(j+1)>1
                    slv=1;
                    xlin(j+1)=0;
                end
            else
                xlin(j+1)=xlin(j)-1;
                if xlin(j+1)<-1
                    slv=0;
                    xlin(j+1)=0;
                end
            end
        else
            xlin(j+1)=xlin(j);
        end
    end
    %To four times of sampling rate with proper rising time
    xlinl=zeros(1,1281);
    for j=1:319
        xlinl(j*4+1:j*4+5)=xlinl(j*4+1:j*4+5)+xlin(j+1)*[0.5 1 1 1 0.5];
    end
    pspc=pspc+abs(fft(xlinl,2048));
end
pspc=pspc/256;
pspc=pspc.^2/100/0.001/125e6/4;
figure(1)
logpspc=10*log10(pspc(1:1024));
f=[1:2048]/2048*5e8;
plot(f(1:511),logpspc(1:511))
grid
xlabel('Frequency (Hz)')
ylabel('PSD (dBm/Hz)')

Contact us