clc
clear;
close all;
N=8;
bitstream=[1 -1 -1 1 1 1 -1 1];
figure(1)
subplot(111)
stem(bitstream);
title('输入的二进制序列');
xlabel('码元间距')
ylabel('码元')
fc=10; %载波频率
fs=1800; %采样频率
T=0.2; %每符号持续时间
N_samples=T*fs; %每符号内的采样点数
t=0:T/N_samples:(T-T/N_samples);
%串并转换
figure(2)
in1=zeros(1,N/2);
in2=zeros(1,N/2);
for i=1:N/2
in1(i)=bitstream(2*(i-1)+1);
in2(i)=bitstream(2*(i-1)+2);
end
subplot(211)
stem(in1);
title('I支路分量')
xlabel('码元间距')
ylabel('码元')
subplot(212)
stem(in2);
title('Q支路分量')
xlabel('码元间距')
ylabel('码元')
carrier1=cos(2*pi*fc*t);
carrier2=sin(2*pi*fc*t);
n=length(bitstream)/2;
x1=zeros(1,length(carrier1)*n);
y1=zeros(1,length(carrier1)*n);
for i=1:length(in1)
x1((N_samples*(i-1)+1):(N_samples*(i-1)+N_samples))=in1(i)*carrier1;
end
%载波调制
figure(3)
t1=0:T/N_samples:((length(x1)/N_samples)*T-T/N_samples);
subplot(211)
plot(t1,x1)
axis([0 0.4 -3 3 ]);
title('I支路分量加载波信号')
xlabel('时间/s')
ylabel('幅值')
grid on;
for i=1:length(in2)
y1((N_samples*(i-1)+1):(N_samples*(i-1)+N_samples))=in2(i)*carrier2;
end
subplot(212)
plot(t1,y1)
axis([0 0.4 -3 3 ]);
title('Q支路分量加载波信号')
xlabel('时间/s')
ylabel('幅值')
grid on;
figure(4)
z1=x1+y1;
subplot(111)
plot(t1,z1)
axis([0 0.4 -3 3 ]);
title('QPSK调制信号')
xlabel('时间/s')
ylabel('幅值')
grid on;
k = 2; % 每个符号的比特数
EbNo = 5; % 解调门限In dB
nsamp = 1; % 采样率
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
z2 = awgn(z1,snr,'measured');
figure(5)
for i=1:length(z2)/N_samples
x2((N_samples*(i-1)+1):(N_samples*(i-1)+N_samples))=carrier1;
end
x3=z2.*x2;
subplot(211)
plot(t1,x3)
axis([0 0.4 -3 3 ]);
title('I支路分量相干解调信号')
xlabel('时间/s')
ylabel('幅值')
grid on;
for i=1:length(z2)/N_samples
y2((N_samples*(i-1)+1):(N_samples*(i-1)+N_samples))=carrier2;
end
y3=z2.*y2;
subplot(212)
plot(t1,y3)
axis([0 0.4 -3 3 ]);
title('Q支路分量相干解调信号')
xlabel('时间/s')
ylabel('幅值')
grid on;
%加噪信号通过滤波器
[b,a]=butter(3,0.1);
x3=filter(b,a,x3);
[b,a]=butter(2,0.1);
y3=filter(b,a,y3);
figure(6)
subplot(211)
plot(t1,x3);
axis([0 0.2 -3 3 ]);
title('I支路分量相干解调信号通过滤波器')
xlabel('时间/s')
ylabel('幅值')
grid on;
subplot(212)
plot(t1,y3);
axis([0 0.2 -3 3 ]);
title('Q支路分量相干解调通过滤波器')
xlabel('时间/s')
ylabel('幅值')
grid on;
out1=zeros(1,length(x3)/(2*N_samples));
for i=0:(N/2-1)
if(x3(N_samples*i+N_samples/2)>0)
out1(i+1)=1;
else
out1(i+1)=-1;
end
end
out2=zeros(1,length(y3)/(2*N_samples));
for j=0:(N/2-1)
if(((y3(N_samples/4+N_samples*j)+y3((N_samples*3)/4+N_samples*j))/2)>0)
out2(j+1)=1;
else
out2(j+1)=-1;
end
end
out=zeros(1,length(bitstream));
for k=1:length(bitstream)/2
out(2*(k-1)+1)=out1(k);
out(2*(k-1)+2)=out2(k);
end
figure(7)
subplot(211)
stem(out);
title('QPSK输出信号')
ylabel('幅值')
axis([0 8 -1 1]);
spectrum=(real(fft(z1,10*length(z1)))).^2;
S_spectrum=spectrum(1:length(spectrum)/2);
subplot(212)
F=0:fs/(2*length(S_spectrum)):fs/2-fs/(2*length(S_spectrum));
plot(F,10*log10(S_spectrum))
axis([0 50 0 60]);
title('QPSK信号功率谱密度')
xlabel('频率/Hz')
ylabel('功率')
snr=0:0.5:10;
ber=1-(1-1/2*erfc(sqrt(0.4*snr))).^2;
figure(8)
semilogy(log(snr),ber,'-b*')
title('QPSK信号误码率分析')
xlabel('信噪比')
ylabel('误码率')


fpga和matlab
- 粉丝: 18w+
- 资源: 2657
最新资源
- Fluent激光焊接模拟技术:基于椎体热源模型与双椭球热源模型的小孔动态行为研究,考虑反冲压力、表面张力、热浮力及热损失因素,利用CSF公式平滑处理反冲压力,灵活调整材料参数的数值模拟方法,涵盖参考文
- read-camera.py 这段 Python 代码的主要功能是同时从多个摄像头读取视频帧,将每个摄像头读取的帧存储在队列中,并按照一定的时间间隔将这些帧保存为 BMP 图像文件
- 光端机带485回传原理图
- VSG预同步控制与电流双环控制的Matlab仿真模型研究及电力电子入门指南,基于Matlab的VSG预同步控制仿真模型:涵盖并网逆变器、VSG控制及电流双环管理等多模块研究参考文献详实电力电子仿真入门
- 远程监控直流电源(普源DP932U)
- 远程监控直流电源(普源DP932U)
- JAVA30道面试题.zip
- 基于Matlab Simulink仿真的电气工程自动化:直驱永磁同步电机与风力机最大功率跟踪技术结合制氢的孤岛pwm调制技术探索,基于Matlab Simulink仿真的电气工程自动化:直驱永磁同步电
- 酒店管理系统设计与实现
- 720p模拟光端机接收原理图CPLD
- 16进制数据校验软件,方便计算16进制数组常用校验值
- 撒大大阿达阿达把v吃不吃VB
- 三菱PLC与组态王协同的自动蜂窝煤生产线控制系统设计:五传送带控制系统的策略与PLC程序设计,基于三菱PLC与组态王设计的自动蜂窝煤生产线五传送带控制系统优化与程序设计研究,三菱PLC和组态王自动蜂窝
- C语言常见数据类型总结
- 西门子Smart PLC四轴搬运取料机案例程序:从新手到项目的跃升之路,西门子Smart PLC四轴搬运取料机运动控制案例程序-PLC通信与伺服电机自动化控制解决方案,西门子200smart运动控制
- mysql面试题参考.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
前往页