差分编码
function Y = difference(X)
%UNTITLED Summary of this function goes here % Detailed explanation goes here
a=length(X);
Y=zeros(1,a);
b=0.01:0.01:a;
for(i=1:a)
is((i-1)*100+1:i*100)=X(i);
end
figure
plot(b,is);
axis([0,a+1,-0.1,1.1]);
title('原始序列')
grid
if (X(1)==1)
Y(1)=1;
else Y(1)=0;
end
for i=2:a
if(X(i)-X(i-1)~=0)
Y(i)=1;
else Y(i)=0;
end
end
Y;
t=0.01:0.01:a;
for(i=1:a)
st((i-1)*100+1:i*100)=Y(i);
end
figure
plot(t,st);
axis([0,a+1,-0.1,1.1]);
title('差分编码')
grid
end