展开全部
clear
clc
pntaps=[0 0 1 1 ];
N=length(pntaps)
pninitial=[0 0 0 1];
pndata=zeros(1,2^N-1);
pnregister=pninitial;
n=0;kk=0;
while kk==0
n=n+1;
pndata(1,n)=pnregister(1,1);
feedback=rem((pnregister*pntaps'),2);
pnregister=[feedback,pnregister(1,1:N-1)];
if pnregister==pninitial;
kk=1;
end
end
pndata=2*pndata-1;
Rm(1)=sum(pndata.*pndata)/n
for k=1:n-1
Rm(k+1)=sum(pndata.*circshift(pndata,[0,k]))/n
end
subplot(2,1,1);x=[0:n-1];stem(x,pndata);
title('m序列发生器的输出');
axis([0 30 -1.5 1.5]);
subplot(2,1,2);plot(x,Rm);
title('m序列的自相关函数')
axis([0 30 0 1.5]);
clc
pntaps=[0 0 1 1 ];
N=length(pntaps)
pninitial=[0 0 0 1];
pndata=zeros(1,2^N-1);
pnregister=pninitial;
n=0;kk=0;
while kk==0
n=n+1;
pndata(1,n)=pnregister(1,1);
feedback=rem((pnregister*pntaps'),2);
pnregister=[feedback,pnregister(1,1:N-1)];
if pnregister==pninitial;
kk=1;
end
end
pndata=2*pndata-1;
Rm(1)=sum(pndata.*pndata)/n
for k=1:n-1
Rm(k+1)=sum(pndata.*circshift(pndata,[0,k]))/n
end
subplot(2,1,1);x=[0:n-1];stem(x,pndata);
title('m序列发生器的输出');
axis([0 30 -1.5 1.5]);
subplot(2,1,2);plot(x,Rm);
title('m序列的自相关函数')
axis([0 30 0 1.5]);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询