matlab求分别求下面两个m序列的自相关和互相关
clearclcG=127;%序列长度%Generationoffirstm-sequenceusinggeneratorpolynomial[211]sd1=[0000...
clear
clc
G=127; % 序列长度
%Generation of first m-sequence using generator polynomial [211]
sd1 =[0 0 0 0 0 0 1]; % 移位寄存器初始状态(0000001)
PN1=[]; % 第一个m序列
for j=1:G % 第一个m序列
PN1=[PN1 sd1(7)];
if sd1(1)==sd1(5)
temp1=0;
else temp1=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=sd1(6);
sd1(6)=sd1(7);
sd1(7)=temp1;
end
subplot(2,1,1)
stem(PN1)
title('M-sequence generated by generator polynomial [211]')
%Generation of second m-sequence using generator polynomial [217]
sd2 =[0 0 0 0 0 0 1]; % 移位寄存器初始状态(0000001)
PN2=[]; % 第二个m序列
for j=1:G % 10 001 11
PN2=[PN2 sd2(5)];
if sd2(1)==sd2(5)
temp1=0;
else temp1=1;
end
if sd2(6)==temp1
temp2=0;
else temp2=1;
end
if sd2(7)==temp2
temp3=0;
else temp3=1;
end
sd2(1)=sd2(2);
sd2(2)=sd2(3);
sd2(3)=sd2(4);
sd2(4)=sd2(5);
sd2(5)=temp3;
sd1(6)=sd1(7);
sd1(7)=temp3;
end
subplot(2,1,2)
stem(PN2)
title('M-sequence generated by generator polynomial [217]') 展开
clc
G=127; % 序列长度
%Generation of first m-sequence using generator polynomial [211]
sd1 =[0 0 0 0 0 0 1]; % 移位寄存器初始状态(0000001)
PN1=[]; % 第一个m序列
for j=1:G % 第一个m序列
PN1=[PN1 sd1(7)];
if sd1(1)==sd1(5)
temp1=0;
else temp1=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=sd1(6);
sd1(6)=sd1(7);
sd1(7)=temp1;
end
subplot(2,1,1)
stem(PN1)
title('M-sequence generated by generator polynomial [211]')
%Generation of second m-sequence using generator polynomial [217]
sd2 =[0 0 0 0 0 0 1]; % 移位寄存器初始状态(0000001)
PN2=[]; % 第二个m序列
for j=1:G % 10 001 11
PN2=[PN2 sd2(5)];
if sd2(1)==sd2(5)
temp1=0;
else temp1=1;
end
if sd2(6)==temp1
temp2=0;
else temp2=1;
end
if sd2(7)==temp2
temp3=0;
else temp3=1;
end
sd2(1)=sd2(2);
sd2(2)=sd2(3);
sd2(3)=sd2(4);
sd2(4)=sd2(5);
sd2(5)=temp3;
sd1(6)=sd1(7);
sd1(7)=temp3;
end
subplot(2,1,2)
stem(PN2)
title('M-sequence generated by generator polynomial [217]') 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询