[Energy detection] Matlab simulation of energy detection algorithm based on cognitive radio

1. Software version

matlab2021a

2. Theoretical knowledge of this algorithm

      With the rapid development of wireless communication, users have higher and higher requirements for communication quality, and at the same time, the substantial growth of wireless devices makes spectrum resources more important. Cognitive Radio (CR) technology is regarded as a powerful technology to solve the shortage of spectrum resources and improve spectrum utilization, and is an important component of next-generation communication technology. Spectrum sensing is a key technology implemented by cognitive radio technology. Spectrum sensing technology is used to sense spectrum holes in the channel, so that cognitive users can use spectrum holes to transmit information, thereby alleviating the tension between spectrum resource shortage and communication service requirements. contradiction. Here is a brief introduction to a more classic method of spectrum sensing-Energy Detection (ED).

3. Part of the core code

clc;
clear;
close all;

%选择信道模型
sel = 1;%1:高斯信道;0:莱斯信道
SNR = 10;%信噪比
%生成bpsk调制信号
fs=100;
%采样频率
fc=30;
%载频
fo=fs/20;
%码率
L=4000;
%信号样本
t = (0:L-1)*1/fs;
xn=cos(8*pi*fc*t);%产生最为简单的BPSK信号      
if sel == 1
y = AWGN(xn,SNR);%高斯信道
else
c = rayleighchan(1/fs,0.001);%rayleigh信道
y = filter(c,xn);  
end
% chan = rayleighchan(Ts,fd,tau,pdb)
% Ts  :采样时间,如果考虑基带信号,这个和接收机要处理的数据速率是一样的,要考虑过采样的影响
% fd  :就是Doppler频偏,以Hz为单位,与速率的换算关系为v×fc/c,fc是载频
figure(1)
subplot(121);plot(t,y);title('产生的BPSK信号');
%进行能量检测
NFFT = 2^nextpow2(L);
Y = fft(y,NFFT)/L;%第一步,进行FFT变换
f = fs/2*linspace(0,1,NFFT/2);
subplot(122);plot(f,2*abs(Y(1:NFFT/2)),'r-*');title('能量检测效果');
%计算能量
Po = sum(abs(Y).^2);
%进行判决,分为data fusion 和 decision fusion两种方法
%本部分是检测算法的



4. Simulation conclusion

5. References

A01-35

6. How to obtain the complete source code

Method 1: Wechat or QQ to contact the blogger
Method 2: Subscription , free access to the tutorial case code and any 2 complete source code of this blog

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/124327051