欢迎来到天天文库
浏览记录
ID:47322916
大小:38.01 KB
页数:4页
时间:2020-01-10
《2FSK信号的调制与解调matlab程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、clearall;closeall;f=300;t=2*(0:0.001:1-0.01)/f;x=t;singal=sin(2*pi*f*x)+1;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%u率PCM编码%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%a=singal;n=8;%u率非线性u=255;%%%%%%%%%%%%待考察,应该是255%%%%%%c=zeros(size(a));fori=1:length(a)c(i)=log(1+u*a(i))/log(1+u);%在PCM中要求x应该大于0endcmax=max(c);cmin
2、=min(c);%均匀量化c_quan=c;b_quan=c_quan;d=(cmax-cmin)/n;%此处有问题%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%自己写的量化代码%%%%%%%%%%%%forj=1:n+1kk(j)=cmin+j*d;endfork=1:nq(k)=(kk(k)+kk(k+1))/2;end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fori=1:nm=find((q(i)-d/2<=c_quan)&(q(i)+d/2>=c_quan));c_quan(m)=q(i).*
3、ones(1,length(m));b_quan(find(c_quan==q(i)))=(i-1).*ones(1,length(find(c_quan==q(i))));end%编码nu=ceil(log2(n));code=zeros(length(a),nu);fori=1:length(a)forj=(nu-1):-1:0if(fix(b_quan(i)/(2^j))==1)code(i,(nu-j))=1;b_quan(i)=b_quan(i)-2^j;endendendbitstorm=[];fori=1:length(code)bitstorm=[bitstorm,co
4、de(i,:)];end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%FSK调制的实现%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%figure(1)subplot(221);stairs(bitstorm(1:20));title('调制信号');axis([0,20,-0.1,1.2]);gridon%%%%%%%%%%%%%这是设置随机数值%%%%%%%%%%%%%%%%%%%%%%%rand('state',sum(100*clock));randn('state',sum(100*clock));min
5、testlongth=1000;maxtestlongth=1000;A=1;Eb=A*A;SNR=10;%信噪比index=1;%forSNR1=0:10disp('程序在运行,请稍等.....');N0=Eb*10^(-SNR/10);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%待解决noiseVar=N0/2;%噪声密度noiseRoot=sqrt(noiseVar)%噪声的均方差errorCount=0;testCount=0;f1=1;f2=2;mm=0:0.02:1-0.02;%抽样判决在t轴上的抽样矩阵i=0;DemoFSK=zeros(1,min
6、testlongth);FSK=zeros(1,10*length(mm));%%%%%%%%%%%%%%%%%%%%这是为什么noise_FSK=zeros(1,10*length(mm));while(1)i=i+1;%%%%%%%%%%%%%%%%%%%%调制解调src=bitstorm(i);src1=src;src2=1-src;noise=noiseRoot.*randn(1,length(noiseRoot));%高斯白噪声矩阵fsk=cos(2*pi*f1*mm)*src1+cos(2*pi*f2*mm)*src2;noise_fsk=fsk+noise;ifi<=10
7、FSK(1+length(mm)*(i-1):length(mm)*i)=fsk;%修改过%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%noise_FSK(1+length(mm)*(i-1):length(mm)*i)=noise_fsk;endofsk1=noise_fsk.*cos(2*pi*f1*mm);ofsk2=noise_fsk.*cos(2*pi*f2*m
此文档下载收益归作者所有