数字通信原理NRZ,NRZI,MILLER码的MATLAB编程
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SIMULATION AND PERFORMANCE ANALYSIS OF
BASEBAND TRANSMISSION
1. Generate a random binary sequence with 1000 bits, in which the probability of “0” is 0.8 and the probability of “1” is 0.2, respectively. Code:
>> NRZ=randsrc(1,1000,[1,0;0.2,0.8])
2. Plot the first 20 bits of the binary sequence as the NRZ signals.
>> for i=1:20
NRZ_plot(i)=NRZ(i);
end
>> figure(1);
subplot(3,1,1)
>> stairs(NRZ_plot)
3. Transfer the random binary sequence to the NRZI signals and Miller codes. Plot the first 20 bits of the NRZI and Miller Code waveforms.
The waveform sampling rate is set to 8 times the symbol rate (oversampling rate equals to 8).
>> for i=1:1:999;
NRZI(i+1)=NRZ(i+1)-NRZ(i);
if(NRZI(i)==-1);
NRZI(i)=1;
NRZI(1)=NRZ(1);
end;
end;
>>for i=1:19
NRZI_plot(i)=NRZI(i);
end
stairs(NRZI_plot);
miller=rand(1,8*k);%get the miller code
for i=1:k
if NRZ(i)==1%when the nrz==1
if i==1%the initialization when nrz==1
for j=0:3
miller(8*i-7+j)=1;
end
for j=4:7
miller(8*i-7+j)=0;
end
else%the normal situation when nrz==1
for j=0:3
miller(8*i-7+j)=miller(8*i-8);
end
for j=4:7
miller(8*i-7+j)=1-miller(8*i-8);
end
end
else%when the NRZ==0
if i==1%the initialization when nrz==0
for j=0:7
miller(8*i-7+j)=0;
end
elseif NRZ(i-1)==1%when the front one is 1
for j=0:7
miller(8*i-7+j)=miller(8*i-8);
end
else%when the front one is 0
for j=0:7
miller(8*i-7+j)=1-miller(8*i-8);
end
end
end
end;
for i=1:160
miller_plot(i)=miller(i);
end;
%subplot(3,1,3);
stairs(miller_plot);
>> subplot(3,1,1);
>> stairs(NRZ_plot);
>> subplot(3,1,2);
>> stairs(NRZI_plot);
>> subplot(3,1,3);
>> stairs(miller_plot)
4. Estimate the power spectrums of these different baseband signals and plot them. Pay attention to the differences between these power spectrums.
The code:
for i=1:1000
for k=0:7
nrz(8*i-k)=NRZ(i);
nrzi(8*i-k)=NRZI(i);
end
end
nrzfft=fft(nrz);%get the fft of nrz
subplot(3,1,1);
plot(abs(nrzfft).^2);%plot the power spectrum of nrz
axis([0 8000 0 350000]);
nrzifft=fft(nrzi);%get the fft of nrzi
subplot(3,1,2);
plot(abs(nrzifft).^2);%plot the power spectrum of nrzi
axis([0 8000 0 350000]);
millerfft=fft(miller);%get the fft of miller
subplot(3,1,3);
plot(abs(millerfft).^2);%plot the power spectrum of miller
axis([0 8000 0 350000]);
5. Change the probability of “0”, and see what will happen.\ The changed code:
NRZ=randsrc(1,1000,[1,0;0.5,0.5])
And the other code are the same as the original
The picture of waveforms are:
Then the picture of spectrums are :
6. experience
From this experiment I have learnt how to use matlab. Meanwhile, I have recognized the NRZ, NRZI, MILLER codes’ principles and ways of encoding. And it takes me more than 5 hours to accomplish this work and time to write this report, which makes me tough. Anyhow, I appreciate every chance of lab works.。