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