您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 冶金工业 > MATLAB实现伪随机码的生成及相关函数的计算
伪随机码的生成及相关函数的计算院系:信息学院专业:通信工程姓名:2013117100王卓2013117101席倩2013117103薛珈萍(1)函数ms_generator(registers,connections)是m序列的生成函数,其中参数registers给出了移位寄存器的初始状态,connections给出了m序列的发生器代码:functionseq=ms_generator(registers,connections)%registers=[00001];%设置初始状态%connections=[100101];%设置反馈逻辑n=length(connections);L=2^(n-1)-1;seq(1)=registers(n-1);fori=2:Lsum=0;form=1:(n-1)sum=mod(sum+registers(m)*connections(m+1),2);endfork=(n-1):-1:2;registers(k)=registers(k-1);endregisters(1)=sum;seq(i)=registers(n-1);end调用程序:functionseq=ms_generator(registers,connections)clcclearregisters=[00001];connections=[100101];seq=ms_generator(registers,connections)结果:seq=1000010010110011111000110111010ans=1000010010110011111000110111010(2)auto_corr()代码:functionauto_correlation=auto_corr(seq)registers=[10000];%设置初始状态connections=[101001];%设置反馈逻辑seq=ms_generator(registers,connections);seq=-1*(seq*2-1);%负逻辑映射len=length(seq);temp=[seqseq];fori=0:len-1auto_correlation(i+1)=seq*(temp(i+1:i+len))';endauto_correlationplot(0:len-1,auto_correlation);结果:auto_correlation=31-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1ans=31-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1(3)cross_corr()代码:functioncross_correlation=cross_corr(seq1,seq2)registers1=[00001];%设置初始状态connections1=[100101];%设置反馈逻辑seq1=ms_generator(registers1,connections1);seq1=-1*(seq1*2-1);%负逻辑映射registers2=[11111];%设置初始状态connections2=[111101];%设置反馈逻辑seq2=ms_generator(registers2,connections2);seq2=-1*(seq2*2-1);%负逻辑映射temp=[seq2seq2];len=length(seq2);fori=0:len-1cross_correlation(i+1)=seq1*(temp(i+1:i+len))';endauto_correlation=auto_corr(seq1)plot(0:len-1,auto_correlation,'-.',0:len-1,cross_correlation);结果:(4)GOLD码代码functiongold=gold()registers1=[100000];connections1=[1100001];seq1=ms_generator(registers1,connections1);registers2=[100000];connections2=[1110011];seq2=ms_generator(regerters2,connections2);temp=[seq2seq2];len=length(seq2);fori=1:lengold(i,:)=mod(seq1+temp(i:i+len-1),2);endgold(len+1,:)=seq1;gold(len+2,:)=seq2;plot(0:len-1,auto_corr(gold(1,:)),'-',0:len-1,cross_corr(gold(1.:),gold(2,:)),'-.');结果:相关特性:(5)Walsh函数:代码:functionwalsh=walsh(L)L=64n=log2(L);temp=[0];temp2=zeros(4,4);fori=1:ntemp2=zeros(2.^n,2.^n);temp1=inverse(temp);temp2=[temptemp;temptemp1];temp=zeros(2.^n,2.^n);temp=temp2;temp1=zeros(2.^n,2.^n);endwalsh=temp2;correlation=(walsh*2-1)*(walsh*2-1)'functionresult=inverse(temp)len=size(temp);fori=1:lenforj=1:len;if(temp(i,j)==0)temp(i,j)=1;elsetemp(i,j)=0;endendendresult=temp;结果:因篇幅受限只截取其中一部分。
本文标题:MATLAB实现伪随机码的生成及相关函数的计算
链接地址:https://www.777doc.com/doc-2170443 .html