generate binary data b_k using randint.

2. define the sampling time, and the data rate. For example, data rate can be R=10kbps, T=1/R, and sampling time Ts=T/40;

3. according to the above define your pulse shape (wave form of the different line codes).

4. obtain the x(t)=\sum_{k=-100}^{100} d_k p(t-kT)

d_k should be correctly mapped from the b_ks generated above.

5. plot the resulting x(t) for the different line codes.

6. obtain the autocorrelation function of x(t) (you may need to average over many realization (10-50 realizations should be enough to get smooth curve).

7. obtain the power spectral density by performing FFT of the autocorrelation function.

8. plot the power spectral density.

solution :

function f1=unipolar_nrz(b,R,Ns)

b=randint(1,100);

R=10000; %data rate: 10kbps

Tb=1/R; %bit duration

Nb=length(b);

Ts=Tb/4000;

Fs=1/Ts;

Ns=100; %40 samples/bit

d=b;

pulse=ones(1,Ns);

t=0:Ts(Ns*Nb)*Ts)-Ts;

x=kron(d,pulse); %Kronecker tensor product

%y1 = wgn(100,1,0);

plot(t,x)

%y= X+ 0.00001*y1;

D= pwelch(x,33,32,[],Fs,'twosided');

hold

%D2=D+randn;

plot(fftshift(D))

end

>>b = rand(100,1);

>>R=10000;

>>Tb=1/R;

>>Ts=Tb/40;

>>Nb=length(b);

>>Ns=40;

>>pulse =[ones(1,Ns/2), -ones(1,Ns/2)];

>>t=0:Ts(Ns*Nb).*Ts)-Ts;

>>f=0:0.05*Rb:2*Rb;

>>x=f*Tb;

>>d=b;

>>x=kron(d,pulse);

n=1

m=1

b = randint (n)

b = randint (n,m)

b = randint (n,m,[0:1])

R=10000

T=1/R

%sampling time

Ts=T/40

if any can complete and correct , i am ganna be so plzd