0% found this document useful (0 votes)
34 views6 pages

Cesar Cárdenas Flores - Cod: 040045F: Function

The document contains MATLAB code to generate three different line codes: 1) Polar NRZ line code that encodes bits as either -1 or 1 based on the previous bit. 2) Bipolar RZ line code that encodes bits as either -1 or 1 shifted by 0.5 units of time based on the previous bit. 3) AMI Bipolar RZ line code that encodes bits as either -1 or 1 shifted by 0.5 units of time and inverts the amplitude of subsequent 1s based on the previous bit and amplitude.

Uploaded by

AnonimusCKF
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views6 pages

Cesar Cárdenas Flores - Cod: 040045F: Function

The document contains MATLAB code to generate three different line codes: 1) Polar NRZ line code that encodes bits as either -1 or 1 based on the previous bit. 2) Bipolar RZ line code that encodes bits as either -1 or 1 shifted by 0.5 units of time based on the previous bit. 3) AMI Bipolar RZ line code that encodes bits as either -1 or 1 shifted by 0.5 units of time and inverts the amplitude of subsequent 1s based on the previous bit and amplitude.

Uploaded by

AnonimusCKF
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Cesar Crdenas Flores - Cod: 040045F

POLAR NRZ
function y=PNRZ(h)
clf;
n=1;
L=length(h);
h(L+1)=1;
while n<=length(h)-1;
t=n-1:0.01:n;
if h(n) == 0
if h(n+1) == 0
y=-(t<n)-(t==n);
else
y=-(t<n)+(t==n);
end
d = plot(t,y); grid on;
title('POLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)== 0
y=(t<n)-1*(t==n);
else
y=(t<n)+1*(t==n);
end
d = plot(t,y); grid on;
title('POLAR NRZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
>> h = [0 1 1 0 1 0 0 1 0 1 1 1 0 0];
>> PRNZ(h);

BIPOLAR RZ
function y=BIRZ(h)
clf;
n=1;
L=length(h);
h(L+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1) == 0
y=-(t<n-0.5)-(t==n);
else
y=-(t<n-0.5)+(t==n);
end
d = plot(t,y); grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)== 0
y=(t<n-0.5)-1*(t==n);
else
y=(t<n-0.5)+1*(t==n);
end
d = plot(t,y); grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
>> h = [0 1 1 0 1 0 0 1 0 1 1 1 0 0];
>> BIRZ(h);

PROBLEMA 3:
Realizar un m-file para el cdigo AMI BRZ
AMI BIPOLAR RZ
function y=AMIBRZ(h)
clf;
n=1;
L=length(h);
h(L+1)=1;
ami=-1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1) == 0
y=(t>n);
else
if ami == -1
y=(t==n); %ami else
y=-(t==n); %ami +
end
end
d = plot(t,y); grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)== 0
if ami == -1
y=(t<n-0.5); %ami ami=(-1)*ami;
else
y=-(t<n-0.5); %ami +
ami=(-1)*ami;
end
else
if ami == -1
y=(t<n-0.5)-1*(t==n); %ami ami=(-1)*ami;
else
y=-(t<n-0.5)+(t==n); %ami +
ami=(-1)*ami;
end
end
d = plot(t,y); grid on;
title('BIPOLAR RZ');
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
pause;
end
>> h = [0 1 1 0 1 0 0 1 0 1 1 1 0 0];
>> AMIBRZ(h);

You might also like