clear all
close all
clc
%全局变量
%N=2^12 %宽度,或称为点数
Ts=0.01 %时间分辨率(时间间隔),抽样时间间隔
t=0:Ts:10 %时间坐标
N=length(t)
fs=1/Ts
df=fs/(N-1) %df为频率分辨率(频率间隔)
n=-(N-1)/2:(N-1)/2
f=n*df %频率坐标
%基带信号
figure
p=[1 0 1 1 0 1 0 0 1 1] %待传送的编码串,可用randint(1,n)产生信源;若用rand(1,n,M),则范围是1~M-1
d1=[0:1:t(end)-1] %每个编码的发送延迟时间
p1=[p,zeros(length(d1)-length(p))] %在发送串后补零
d=[d1;p1]' %产生d矩阵
m=pulstran(t-0.5,d,'rectpuls')
subplot(2,1,1)
plot(t,m)
axis([t(1) t(end) -0.5 1.5])
grid on
title('基带信号p')
%基带信号频谱
M=fft(m)
M=fftshift(M)
subplot(2,1,2)
plot(f,abs(M)/N)
title('基带信号频谱')
%抽取IQ信号 BPSK只映射一路I。QPSK两个基带符号为一组,映射到一对IQ
figure
pQI=reshape(p,2,5)
pQ=pQI(1,:)
pI=pQI(2,:)
d2=[0:2:t(end)-2]
dQ=[d2;pQ]'
dI=[d2;pI]'
mI=pulstran(t-1,dI,'rectpuls',2)
mQ=pulstran(t-1,dQ,'rectpuls',2)
subplot(2,1,1)
plot(t,mI)
axis([t(1) t(end) -0.5 1.5])
grid on
title('I路抽取')
subplot(2,1,2)
plot(t,mQ)
axis([t(1) t(end) -0.5 1.5])
grid on
title('Q路抽取')
%IQ值映射 “0”映射成1,“1”映射成-1
figure
I(pI==1)=-1
I(pI==0)=1
Q(pQ==1)=-1
Q(pQ==0)=1
dImap=[d2;I]'
dQmap=[d2;Q]'
mImap=pulstran(t-1,dImap,'rectpuls',2)
mQmap=pulstran(t-1,dQmap,'rectpuls',2)
subplot(2,1,1)
plot(t,mImap)
axis([t(1) t(end) -1.5 1.5])
grid on
title('映射后的I路信号')
subplot(2,1,2)
plot(t,mQmap)
axis([t(1) t(end) -1.5 1.5])
grid on
title('映射后的Q路信号')
%载波信号
fc=5 %载波频率
c1=cos(2*pi*fc*t)
c2=sin(2*pi*fc*t)
%载波信号频谱
figure
C1=fft(c1)
C1=fftshift(C1)
subplot(2,1,1)
plot(f,abs(C1)/N)
title('载波cos频谱')
C2=fft(c2)
C2=fftshift(C2)
subplot(2,1,2)
plot(f,abs(C2)/N)
title('载波sin频谱')
%已调信号
figure
s1=mImap.*c1
subplot(3,1,1)
plot(t,s1)
axis([t(1) t(end) -1.5 1.5])
title('I路调制cos')
grid on
s2=mQmap.*c2
subplot(3,1,2)
plot(t,s2)
axis([t(1) t(end) -1.5 1.5])
title('Q路调制sin')
grid on
s=s1-s2
subplot(3,1,3)
plot(t,s)
axis([t(1) t(end) -1.5 1.5])
title('进入信道的信号s=s1-s2')
grid on
%已调信号频谱
figure
S1=fft(s1)
S1=fftshift(S1)
subplot(3,1,1)
plot(f,abs(S1)/N)
title('s1频谱')
S2=fft(s2)
S2=fftshift(S2)
subplot(3,1,2)
plot(f,abs(S2)/N)
title('s2频谱')
S=fft(s)
S=fftshift(S)
subplot(3,1,3)
plot(f,abs(S)/N)
title('s频谱')
%通过信道后接收到信号
figure
r=awgn(s,10)
subplot(2,1,1)
plot(t,r)
axis([t(1) t(end) -1.5 1.5])
title('接收信号时域')
%接收信号的频谱
R=fft(r)
R=fftshift(R)
subplot(2,1,2)
plot(f,abs(R)/N)
title('接收信号频域')
%解调
figure
y1=r.*c1
subplot(2,1,1)
plot(t,y1)
axis([t(1) t(end) -1.5 1.5])
title('I路解调')
y2=r.*(-c2)
subplot(2,1,2)
plot(t,y2)
axis([t(1) t(end) -1.5 1.5])
title('Q路解调')
%解调后从时域积分(求和)判决
y1sum=0
y2sum=0
for i=1:5
y1sum(i)=sum(y1(200*(i-1)+1:200*i))
y2sum(i)=sum(y2(200*(i-1)+1:200*i))
end
y1d=sign(y1sum)
y2d=sign(y2sum)
%反映射
y1rmap(y1d==1)=0
y1rmap(y1d==-1)=1
y2rmap(y2d==1)=0
y2rmap(y2d==-1)=1
yrmap=[y2rmap;y1rmap]
yrd=reshape(yrmap,1,10)
figure
dr=[d1;yrd]'
receive=pulstran(t-0.5,dr,'rectpuls')
subplot(2,1,1)
plot(t,receive)
axis([t(1) t(end) -0.5 1.5])
grid on
title('接收判决出的信号')
num=biterr(p,yrd)/length(p)
QPSK.rar_QPSK 图像_matlab 数字通信系统_数字通信
版权申诉
47 浏览量
2022-09-21
08:46:44
上传
评论 1
收藏 1KB RAR 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+
最新资源
- 微信小程序 - 图书管理系统源码.zip
- 微信小程序 - 图片自适应 ,富文本解析源码.zip
- 微信小程序 - 同乐居商城:购物车合算源码
- 1、根据输入的三条边值判断能组成何种三角形,并设计测试数据进行判定覆盖测试 三条边为变量a、b、c,范围为1≤边值≤10,不在范
- SQL server 练习题目8道(小白教学).zip
- Python 手写实现 iD3 决策树算法-根据信息增益公式.zip
- 411675952289057车联助手-小窗版(三星)3.5.1.apk
- 三种快速排序方法合并在一个文件中以便直接运行的Python代码示例
- 937712277954201实习5.word
- 2程序语言基础知识pdf1_1716337722703.jpeg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0