2FSK信号的调制与解调matlab程序_第1页
2FSK信号的调制与解调matlab程序_第2页
2FSK信号的调制与解调matlab程序_第3页
2FSK信号的调制与解调matlab程序_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

-clear all;close all;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);for i = 1:length(a) c(i) = log(1+u*a(i)/log(1+u); %在PCM中要求x应该大于0endcmax = max(c);cmin = min(c);%均匀量化c_quan = c;b_quan = c_quan;d = (cmax - cmin)/n; %此处有问题% % % % % % % % % % % % % % % 自己写的量化代码% % % % % % % % % % % %for j = 1:n+1 kk(j) = cmin + j*d;endfor k = 1:n q(k) = (kk(k)+kk(k+1)/2;end% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % for i = 1:n m = find(q(i)-d/2 = c_quan); c_quan(m) = q(i).*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);for i = 1:length(a) for j = (nu-1):-1:0 if (fix(b_quan(i)/(2j)=1) code(i,(nu-j) = 1; b_quan(i) = b_quan(i)-2j; end endendbitstorm = ;for i = 1:length(code) bitstorm = bitstorm,code(i,:);end% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % FSK调制的实现% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % figure(1)subplot(221);stairs (bitstorm(1:20);title(调制信号);axis(0,20,-0.1,1.2);grid on% % % % % % % % % % % % %这是设置随机数值 % % % % % % % % % % % % % % % % % % % % % % % rand(state,sum(100*clock);randn(state,sum(100*clock);mintestlongth = 1000;maxtestlongth = 1000;A = 1;Eb = A * A;SNR = 10; %信噪比index = 1;% for SNR1 = 0:10 disp (程序在运行,请稍等.); 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,mintestlongth); 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; if i = 1/2 DemoFSK(i) = 1; else DemoFSK(i) = 0; end if avo11/2 & avo2 1/2 errorCount = errorCount + 1; elseif avo11/2 & avo2 1/2 errorCount = errorCount + 1; end testCount = testCount + 1; %测试的长度 if (testCount 0) thresholdTestLongth = 1/tempBER; % 根据误码率来确定测试的长度 else thresholdTestLongth = maxtestlongth; end if (testCount = thresholdTestLongth) myTestLength(index) = testCount; myBER(index) = tempBER; mySNR(index) = SNR; index = index + 1; break end end% endsubplot(222),plot(FSK);title (FSK信号);subplot(223),plot(noise_FSK);title (加入噪声的FSK信号);subplot(224),stairs(DemoFSK(1:20),axis(0,20,-0.2,1.2);title(解调后的信号);figure(2);subplot(221),plot(0:length(bitstorm)-1),10*log10(abs(fft(bitstorm);title(调制信号频谱);subplot(222),plot(0:length(FSK)-1),10*log10(abs(fft(FSK);title(FSK信号频谱);subplot(223),plot(0:length(noise_FSK)-1),10*log10(abs(fft(noise_FSK);title(加入噪声的FSK信号频谱);subplot(224),plot(0:length(DemoFSK)-1),10*log10(abs(fft(DemoFSK);title(解调后的信号频谱);figure(3)semilogy(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论