资源简介
通过随机数产生二进制码元,然后进行调制。再将调制信号加入高斯噪声,通过带通滤波器进入解调模块最后抽样判决重建码元。并比较重建后的码元与重建前的区别画出误码率曲线
代码片段和文件信息
clear all;
close all;
clc
Ts = 1;%码元速率
N_sample = 100; %采样速率
dt = Ts / N_sample;
N = 10000; %码元个数
t = 0 : dt : (N * N_sample - 1) * dt;
RAN = randi([01]1N); % 随机0 1序列
gt1 = ones(1N_sample);
code = [];
RAN0 = RAN;
Progressbar=waitbar(0‘Please wait(1/2)...‘);%创建进度条
for i = 1 : N
waitbar(i/N);
if(RAN0(i) == 0)
RAN0(i) = -1;
end
code = [code RAN0(i)*gt1]; %采样后码元
end
close(Progressbar);
fc = 5;
CarrierWave = sin(2*pi*fc*t); %载波信号
BPSK_Wave = code.* CarrierWave; %调制
fft_code1 = fftshift(fft(BPSK_Wave)); % 求序列的频谱
PE1 = 10 * log10(abs(fft_code1) .^ 2 / (N * Ts)); % 公式法求功率谱密度
PEL1 = (-length(fft_code1) / 2 : length(fft_code1) / 2 - 1) / N; % 转换成对应频率(-L/2:L/2-1)*fs/L
%%%%%%%%%%%%%% 绘制信号 %%%%%%%%%%%%%%%%%%
figure (1)
subplot(311);plot(tcode);axis([010-1.51.5]);title(‘码元序列‘);xlabel(‘t/s‘);ylabel(‘幅度‘);%码元序列
subplot(312);plot(tBPSK_Wave);axis([010-1.51.5]);title(‘BPSK波形‘);xlabel(‘t/s‘);ylabel(‘幅度‘);%BPSK波形
subplot(313);plot(PEL1PE1);axis([fc-5fc+5-100100]);xlabel(‘频率/HZ‘);ylabel(‘P/dB‘);title(‘功率谱密度‘);%功率谱密度
%%%%%%%%%%%%%%%%%计算误码率 %%%%%%%%%%%%%%%%%%%
Pe = [];
h=waitbar(0‘Please wait(2/2)...‘);%创建进度条
%%%%%%%%%%%%% 加入高斯噪声 %%%%%%%%%%%%%%%
SNR = -30 : 30;
SNR0 = SNR+10*log10(25);%等效窄带噪声信噪比
for i =1 : length(SNR);
BPSK_Noise = awgn(BPSK_WaveSNR(i));
waitbar(i/length(SNR));
%%%%%%%%%%%%%%%%%带通滤波器%%%%%%%%%%%%%%%%%%%%%%
BPF = fir1(101[(fc-1)/(N_sample/2)(fc+1)/(N_sample/2)]);
BPSK_BPF = filter(BPF1BPSK_Noise);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% BPSK信号的解调(相干)%%%%%%%%%%%%%
% BPSK_Demo = BPSK_Noise.* CarrierWave ;%相干解调
% fp = 1; %截至频率2.5hz
% fcm = 2*fp/N_sample; %归一化频率
% LPF = fir1(30fcm); %反复实验得出阶数
% BPSK_LPF = filter2(LPFBPSK_Demo); %此处不用conv卷积,因为长度增加
fp = 1;
BPSK_LPF = demodulation(BPSK_NoiseCarrierWavefpN_sample); %将带通后解调过程压缩为子函数输出为过低通后波形
%%%%%%%%%%%%%%%% 抽样判决 %%%%%%%%%%%%%%%%%%%
code_back = [];
count = 0;
for q = 1:N*N_sample
if(BPSK_LPF(q) > 0)
code_back = 1;
else
code_back = -1;
end
if (code_back ~= code(q))
count = count + 1;
end
end
error = count / (N*N_sample);
Pe = [Pe error];
end
close(h);
figure (2)
snr = 10.^(0.1.*SNR);
Pe_theor = (erfc(sqrt(snr))).*(1-0.5*erfc(sqrt(snr)));
semilogy(SNR0Pe‘b‘);xlabel(‘SNR/db‘);ylabel(‘误码率‘);hold on;title(‘BPSK误码率曲线‘);
semilogy(SNRPe_theor‘r‘);grid on;legend(‘实际值‘‘理论值‘);axis([-4810^-41])%xlabel(‘SNR/db‘);ylabel(‘误码率/10^x‘);title(‘BPSK误码率曲线‘);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2957 2018-05-31 15:16 BPSK.m
----------- --------- ---------- ----- ----
2957 1
- 上一篇:复合梯形公式与复合辛普森公式MATLAB
- 下一篇:MSK调制解调
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论