设计一个汉明码编码的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

本文来源:https://www.bwwdw.com/article/adh3.html

Top