Documentos de Académico
Documentos de Profesional
Documentos de Cultura
close all;
clear all;
clc
%% Generacion del pulso1
ts=1/8000;%1/128000;
D=1/4000;%1/16000
Tpulso=0:ts:D-ts;
pulso=[ones(1,length(Tpulso)) zeros(1,3*length(Tpulso))];
tp=0:ts:4*D-ts;
% figure(1)
% subplot(2,1,1);plot(tp,pulso);
% subplot(2,1,2);graficafrecuencia1(pulso,1024,8000,'senal','Hz','r');
%% seal muestreada
sm1=[];
for i=1:length(y)
k=y(i)*pulso;
sm1=[sm1 k];
end
ts=1/64000;
t=0:ts:1-ts;
% figure(3)
% subplot(2,1,1);plot(t,sm1);
% subplot(2,1,2);graficafrecuencia1(sm1,1024,64000,'senal
muestreda','Hz','r');
%% seal muestreada
sm2=[];
for i=1:length(y)
k=y(i)*pulso;
sm2=[sm2 k];
end
ts=1/64000;
t=0:ts:1-ts;
% figure(6)
% subplot(2,1,1);plot(t,sm2);
%
subplot(2,1,2);graficafrecuencia1(sm2,1024,64000,'senalmuestreda','Hz',
'r');
%
%% seal muestreada
sm3=[];
for i=1:length(y)
k=y(i)*pulso;
sm3=[sm3 k];
end
ts=1/64000;
t=0:ts:1-ts;
% figure(9)
% subplot(2,1,1);plot(t,sm3);
% subplot(2,1,2);graficafrecuencia1(sm3,1024,64000,'senal
muestreda','Hz','r');
%% seal muestreada
sm4=[];
for i=1:length(y)
k=y(i)*pulso;
sm4=[sm4 k];
end
ts=1/64000;
t=0:ts:1-ts;
% figure(12)
% subplot(2,1,1);plot(t,sm4);
% subplot(2,1,2);graficafrecuencia1(sm4,1024,64000,'senal
muestreda','Hz','r');
%FINALMENTE
smfinal=sm1+sm2+sm3+sm4;%<==================TDM
figure(13)
subplot(2,1,1);plot(t,sm1,t,sm2,t,sm3,t,sm4);
subplot(2,1,2);graficafrecuencia1(smfinal,1024,64000,'senal
muestreda','Hz','g');
PCM
%% Funcion M para la conversin de decimal a binario
function
%
BINARIO = decabin(num)
B = [0 0 0 0 0 0 0 0];
BINARIO = [];
for i=1:length(num)
B = [0 0 0 0 0 0 0 0];
coc = num(i);
c=1;
while(coc>=2)
B(c) = mod(coc,2);
c= c+1;
coc = floor(coc/2);
end;
B(c) = coc;
B = B(8:-1:1);
BINARIO = [BINARIO B];
end;
%% CUANTIZACION
r=8;
L=2^r;
d=2/L;
ini=-(L+1)*d/2;
fin=(L-1)*d/2;
fs=1/64000;
T=1/4000;
aux=0:fs:T/4-fs;
numM=length(aux);
C=1;
for i=1:numM:length(smfinal)
nivel=-(L/2)*d;
for j=ini:d:fin
if(smfinal(i)>=j && smfinal(i)<j+d)
TDMQ(C)=nivel;
C=C+1;
break;
end;
nivel=nivel+d;
end;
end;
y=TDMQ;
%% Generacion del pulso
ts=1/8000;%1/128000;
D=1/4000;%1/16000
Tpulso=0:ts:D-ts;
pulso=[ones(1,length(Tpulso)) zeros(1,length(Tpulso))];
tp=0:ts:length(pulso)-ts;
%% codificacion
p=L*y;
gg=[];
for i=1:length(p)
if p(i)<0
gg=[gg 256+p(i)];
else
gg=[gg p(i)];
end
end
%codificacion a binario
binario=decabin(gg);
ts=1/128000;
t=0:ts:1-ts;
figure(14)
subplot(2,1,1);plot(t,binario);title('Seal Codificada')
subplot(2,1,2);graficafrecuencia1(binario,1024,64000,'senal
Codificada','Hz','r');
%% seal cuantizada
sQ=[];
for i=1:length(y)
k=y(i)*pulso;
sQ=[sQ k];
end
ts=1/64000;
t=0:ts:1-ts;
figure(15)
subplot(2,1,1);plot(t,sQ);title('Seal Cuantizada')
subplot(2,1,2);graficafrecuencia1(sQ,1024,64000,'senal
muestreda','Hz','r');