1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| clear;
b=input('Entrer une séquence binaire\n');
n=length(b);
t=0:0.001:n;
x=1:1: (n+2)*1000;
for i=1 : n
if (b(i)==0))
b_p(i)=-1;
else
b_p(i)=1;
end
ba(x(i*1000: (i+1) *1000))=b(i);
bw(x(i*1000: (i+1) *1000))=b_p(i);
if (mod(i,2)==0)
bow(x(i*1000: (i+1) *1000))=b_p(i);
bow(x((i+1)*1000: (i+2) *1000))=b_p(i);
else
bew(x(i*1000: (i+1) *1000))=b_p(i);
bew(x((i+1)*1000: (i+2) *1000))=b_p(i);
end
if (mod(n,2)~=0)
bow(x(n *1000: (n+1) *1000))=-1;
bow(x((n+1) *1000: (n+2)*1000))=-1;
end
end
ba=ba(1000:end);
bw=bw(1000:end);
bew=bew(1000: (n+1) *1000);
bow=bow(2000: (n+2) *1000);
figure(1)
subplot(2,1,1)
plot(t,bw)
grid on;axis ([0 n -2 +2])
title('Signal converti en niveaux de 1 et -1'); |
Partager