⛄一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【跳频通信】基于matlab跳频通信系统抗干扰仿真【含Matlab源码 4013期】
点击上面蓝色字体,直接付费下载,即可。
获取代码方式2:
付费专栏信号处理(Matlab)
备注:
点击上面蓝色字体付费专栏图像处理(Matlab),扫描上面二维码,付费299.9元订阅海神之光博客付费专栏,凭支付凭证,私信博主,可免费获得5份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:5份本博客上传CSDN资源代码
⛄二、部分源代码
%begin of file*******
%
%*************************************************************************
clc;
clear all;
close all;
%仿真宏参数配置*****
%仿真宏参
SNR = 2:2:14;
SNJ = 2:2:20;
Repeats = 20; % 重复仿真次数
%信号参数
Sim_time = 1; % 仿真时间
sm_rate = 16; % 采样率
Es = 1; % 信号的平均功率
%FSK调制参数
M = 4; % 调制阶数
Tb = 0.01; % 数据比特周期
Lb = log2(M); % 符号比特长度
Ts = LbTb; % 符号周期
fs = 1/Ts; % MFSK的码速率
h = 0.5; % 调制因子
M_deltaf = h/Ts; % MFSK频率的调制间隔
fm = 100000; % MFSK 信号载频中心频率
%调频调制参数
if M == 2 % 跳频周期
fh = fm; % 跳频信号中心频率
Tc = Ts;
else
Tc = Ts/2;
fh = 2fm;
end
Rc = 1/Tc; % 最小单频间隔(码片速率)
Bs = MRc; % MFSK信号带宽(单个信道)
K = 16; % 跳频频率个数
Bt = KBs; % 发射信号带宽(总带宽)
%滤波器参数
fir_len = 48; %滤波器阶数
% fL = mod(2*(fm+2M_deltaf)Ts/sm_rate,1) ;
% fH = mod(2(fm+2M*M_deltaf)*Ts/sm_rate,1);
fL = 0.65;
fH = 0.95;
Ht_W_Bp = fir1(fir_len,[fL,fH]); %带通滤波器
fhbp = 0:1/127:1;
fhm = [ones(1,4) zeros(1,124)];
Ht_lp = fir2(fir_len*2,fhbp,fhm); %低通滤波器
%信道干扰参数
J_type = 2; %干扰类型 1:宽带干扰 2:部分频带干扰
J_fs = 1; %单音干扰频率
J_theta = 0; %单音干扰相位
J_tone = [1/3 1]; %脉冲单音干扰占空比
J_n = floor(J_tone.*K);
%数据编码参数
Encode_type = 1; %编码方式 1、未编码 2、卷积编码
Encode_rate = 0.5; %编码率
Decode_tlen = 5; %译码跟踪长度
%开始仿真*****************
%用户数据
UsrDataLen = Sim_time/Ts;
UsrData = randsrc(1,UsrDataLen,1:M);
%跳频调制
table_fh_len = Sim_time/Tc;
order_f = randsrc(1,table_fh_len,0:K-1); %随机生成跳频表
table_f = fh + (order_f.2-K+1).Bs/2;
FH_sm_rate = floor(sm_rateTc/Ts);
FH_m_phase = zeros(FH_sm_rate,table_fh_len);
for ii = 1:FH_sm_rate
FH_m_phase(ii,:) = table_f;
end
DataLen = FH_sm_ratetable_fh_len;
FH_m_phase = reshape(FH_m_phase,1,DataLen); %跳频频率序列
%MFSK信号跳频调制,采样
[Tn,sm_signal,signalsend] = MyFHFSKMod(UsrData,M,M_deltaf,sm_rate,FH_m_phase,Ts,Es,fm);
%相干解调矩阵
Coheredata = zeros(M,DataLen);
for ii = 1:M
Coheredata(ii,:) = cos(2pi.(fm+ii*M_deltaf.*ones(1,DataLen)).*Tn);
end
signal_FH = cos(2*pi.*FH_m_phase.*Tn); %解跳跳频信号
MFSK = [num2str(M) ‘FSK’];
figure(1);
subplot(2,1,1);
plot(sm_signal(1:500));
grid on;
title([MFSK ‘调制信号’]);
subplot(2,1,2);
plot(abs(fft(sm_signal)));
grid on;
title([MFSK ‘调制信号频谱’]);
figure(2);
subplot(2,1,1);
plot(signalsend(1:500));
grid on;
title([‘FH/’ MFSK ‘信号’]);
subplot(2,1,2);
plot(abs(fft(signalsend)));
grid on;
title([‘FH/’ MFSK ‘信号频谱’]);
%噪声范围
if J_type ~= 1
Jams = zeros(1,DataLen);
SNR = SNJ;
for ii = -floor(J_n(1)/2):floor(J_n(1)/2)
Jams = Jams + cos(2pi(fh + ii.*Bs/2).*Tn);
end
Jams = Jams./J_n(1);
end
%噪声产生
slen = length(signalsend);
Nn = 3;
nlen = Nnslen;
nstate = Nnslen - slen;
nrandseq = randn(1,nlen);
error_rate = zeros(1,length(SNR));
%开始重复迭代
for snr = 1:length(SNR)
error_num = 0;
%干扰方差
Jatp = 10^(SNR(snr)/10);
Es = 1;
Jsgma = sqrt(Es*2/Jatp);
for ii = 1:Repeats
if J_type == 1
%计算噪声序列
nstart = randi(nstate);
s_noise = Jsgma.*nrandseq(nstart+1:nstart+slen);
else
s_noise = Jsgma.*Jams;
end
rcvsignal = signalsend + s_noise; %加干扰
rcvsignal1 = rcvsignal;
rcvsignal = signal_FH.*rcvsignal; %解跳
rcvsignal2 = rcvsignal;
rcvsignal = conv2(rcvsignal,Ht_W_Bp,'same'); %带通滤波
rcvsignal3 = rcvsignal;
RcvUsrData = MyFSKDeMod(rcvsignal,M,sm_rate,Coheredata,Ht_lp);%FSK解调
%判决,计算误码个数
liminal = UsrData - RcvUsrData;
error_num = error_num + length(find(liminal~=0));
end
%由于仿真耗时,所以记录下仿真数据
data_len_totel = Repeats *UsrDataLen;
bit_err_rate = error_num/data_len_totel;
% fprintf(‘%d\t%d\t%d\t%e\n’,SNR(snr),error_num,data_len_totel,bit_err_rate);
error_rate(snr) = bit_err_rate;
if bit_err_rate == 0
break;
end
end
%仿真结束图示结果*********
figure(3);
subplot(2,1,1);
plot(rcvsignal1(1:500));
grid on;
title([‘FH/’ MFSK ‘带干扰信号’]);
subplot(2,1,2);
plot(abs(fft(rcvsignal1)));
grid on;
title([‘FH/’ MFSK ‘带干扰信号频谱’]);
figure(4);
subplot(2,1,1);
plot(rcvsignal2(1:500));
title([‘FH/’ MFSK ‘解跳信号’]);
grid on;
subplot(2,1,2);
plot(abs(fft(rcvsignal2)));
grid on;
title([‘FH/’ MFSK ‘解跳信号频谱’]);
figure(5);
subplot(2,1,1);
plot(rcvsignal3(1:500));
title([MFSK ‘带通滤波后信号’]);
grid on;
subplot(2,1,2);
plot(abs(fft(rcvsignal3)));
grid on;
title([MFSK ‘带通滤波后信号频谱’]);
Error_plot(M,J_type,J_tone,error_rate);
%end of file*****************
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除