设计一个汉明码编码的2PSK调制的数字通信系统
更新时间:2024-06-22 01:25:02 阅读量: 综合文库 文档下载
- 汉明码是一种推荐度:
- 相关推荐
设计一个采用2PSK调制的数字通信系统
??设计系统整体框图及数学模型;
??产生离散二进制信源,进行信道编码(汉明码),产生BPSK信号; ??加入信道噪声(高斯白噪声); ??BPSK信号相干解调,信道解码;
??系统性能分析(信号波形、频谱,白噪声的波形、频谱,信道编解)
实现程序。
clear all; close all; clc;
max = 20;
s=randint(1,max);%长度为max的随机二进制序列 Sinput=[];
for n=1:length(s); if s(n)==0;
A=zeros(1,2000); else s(n)==1;
A=ones(1,2000); end
Sinput=[Sinput A]; end
figure(4); subplot(211); plot(Sinput); grid on
axis([0 2000*length(s) -2 2]); title('输入信号波形');
Sbianma=encode (s,7,4,'hamming');%汉明码编码后序列 a1=[]; b1=[]; f=1000;
t=0:2*pi/1999:2*pi;
for n=1:length(Sbianma); if Sbianma(n)==0;
B=zeros(1,2000);%每个值2000个点 else Sbianma(n)==1; B=ones(1,2000); end
a1=[a1 B];%s(t),码元宽度2000 c=cos(2*pi*f*t);%载波信号
b1=[b1 c];%与s(t)等长的载波信号,变为矩阵形式
end
figure(1); subplot(321) plot(a1); grid on;
axis([0 2000*length(Sbianma) -2 2]);title('二进制信号序列'); a2=[]; b2=[];
for n = 1:length(Sbianma); if Sbianma(n) == 0;
C = ones(1,2000);%每个值2000点 d = cos(2*pi*f*t);%载波信号 else Sbianma(n) == 1; C = ones(1,2000);
d = cos(2*pi*f*t+pi);%载波信号 end
a2 = [a2 C];%s(t),码元宽度2000 b2 = [b2 d];%与s(t)等长的载波信号 end
tiaoz = a2.*b2;%e(t)调制 figure(1); subplot(322); plot(tiaoz); grid on;
axis([571*length(Sbianma) 572*length(Sbianma) -2 2]); title('2psk调制信号'); figure(2); subplot(321); plot(abs(fft(a1)));
axis([0 2000*length(Sbianma) 0 400]); title('原始信号频谱'); figure(2);
subplot(322);plot(abs(fft(tiaoz)));
axis([0 2000*length(Sbianma) 0 400]); title('2psk信号频谱')
%-----------------带有高斯白噪声的信道---------------------- tz=awgn(tiaoz,10);%信号tiaoz加入白噪声,信噪比为10 figure(1); subplot(323); plot(tz); grid on
axis([0 2000*length(Sbianma) -2 2]); title('通过高斯白噪声后的信号'); figure(2); subplot(323); plot(abs(fft(tz)));
axis([0 2000*length(Sbianma) 0 800]); title('加入白噪声的2psk信号频谱'); jiet=2*b1.*tz;%同步解调 figure(1);
subplot(324);plot(jiet);
grid on
axis([0 2000*length(Sbianma) -2 2]);title('相乘后的信号波形') figure(2); subplot(324); plot(abs(fft(jiet)));
axis([0 2000*length(Sbianma) 0 800]); title('相乘后的信号频率');
%----------------------低通滤波器--------------------------- fp=500; fs=700; rp=3; rs=20; fn=11025; ws=fs/(fn/2);
wp=fp/(fn/2);%计算归一化角频率
[n,wn]=buttord(wp,ws,rp,rs);%计算阶数和截止频率 [b,a]=butter(n,wn);%计算H(z) figure(3);
freqz(b,a,1000,11025); subplot(211);
axis([0 40000 -100 3]) title('lpf频谱图'); jt=filter(b,a,jiet); figure(1); subplot(325); plot(jt); grid on
axis([0 2000*length(Sbianma) -2 2 ]); title('经低通滤波器后的信号波形'); figure(2);
subplot(325);plot(abs(fft(jt)));
axis([0 2000*length(Sbianma) 0 800]); title('经低通滤波器后的信号频率');
%-----------------------抽样判决-------------------------- for m=1:2000*length(Sbianma); if jt(m)<0; jt(m)=1; else jt(m)>0; jt(m)=0; end end
figure(1); subplot(326); plot(jt) grid on
axis([0 2000*length(Sbianma) -2 2]); title('经抽样判决后信号jt(t)波形') figure(2); subplot(326); plot(abs(fft(jt)));
axis([0 2000*length(Sbianma) 0 800]); title('经抽样判决后的信号频谱');
grid on;
n=500:2000:2000*length(Sbianma); a5=[];
a5=[a5 jt(n)];
s1=decode (a5,7,4,'hamming'); a6=[];
for n=1:length(s1); if s1(n)==0;
G=zeros(1,2000); else s1(n)==1;
G=ones(1,2000); end
a6=[a6 G]; end
figure(4); subplot(212); plot(a6); grid on
axis([0 2000*length(s) -2 2]); title('汉明码译码后的波形') grid on
正在阅读:
城镇上半年工作总结和下半年工作计划08-08
人教版一年级上学期语文期末试题含答案04-27
方特之旅作文500字06-30
(关兴小学)实施《义务教育学校管理标准》工作自查报告06-28
ARMA模型建模与预测指导11-06
中药化学实验指导—实验一 大黄中游离蒽醌的提取分离与检识09-25
北师大版六年级数学《圆》专项练习03-08
- 八年级英语上册 Unit 10 If you go to the party, you’ll have
- 杨运成简历
- 江苏省盐城市亭湖区2012届九年级下学期第一次调研考试数学试题
- 道桥顶岗实习报告
- 差干镇初中2018-2019学年七年级下学期数学第一次月考试卷
- 数学阅读教学反思
- 阿克苏地区
- 浅析《项羽本纪》
- 称骨断命全书2
- 烘箱使用说明书
- 人教版小学语文一年级至六年级生字表完整版(DOC)
- 五年级第一学期作文教案S版
- 小学二年级英语上学期期末综合试题
- 合成甲缩醛的研究现状概论
- 2018年湖北省襄阳市初中毕业生学业水平考试语文试题解析版
- 监控招标文件 - 图文
- 2万吨污水厂项目投标文件
- 立式储罐预制安装施工方案1 - 图文
- 2016苏教版四年级下册教学设计 第2单元 认识多位数
- CRH1动车组试题汇总(300题修订版)