Matlab simulation of energy detection algorithm based on cognitive radio

Table of contents

1.1 Theoretical research on cognitive radio energy detection algorithm

1.2 MATLAB core program

1.3 Simulation results


1.1 Theoretical research on cognitive radio energy detection algorithm

        The energy detection of cognitive radio is a non-coherent detection method. Its principle is based on the sensor detecting the signal according to the difference in the power of the received signal under two assumptions of whether the signal is present or not. This method is an effective method for the detection of deterministic signals and their existence of unknown parameters. Since energy detection does not impose restrictions on signal types, a priori information about the authorization signal is not required.

        In energy detection, the power of the authorized signal S(t) is averaged within a time period (N sampling points) and then compared with the preset threshold to determine whether there is an authorized signal in the frequency band. Specifically, assuming that the input signal is x(t), after sampling for a period of time (N sampling points), its energy can be expressed as:

E = Σ |x(n)|² (1)

Where n is the sampling point serial number.

       In the threshold comparison stage, E is compared with the preset threshold. If E is greater than or equal to the threshold, it is determined that the authorized signal exists in the frequency band; otherwise, it is determined that there is no authorized signal in the frequency band.

        It should be noted that in practical applications, the choice of threshold has a greater impact on the results of energy detection. Therefore, in order to improve detection accuracy, the threshold usually needs to be adjusted according to the actual situation.

       In addition, cognitive radio energy detection also has certain limitations. For example, when the signal environment is complex, interference may occur between multiple signals, resulting in inaccurate energy detection results. At this time, other detection methods need to be considered, such as feature-based detection methods, frequency domain filtering and other methods to improve detection performance.

       In short, cognitive radio energy detection is a simple and effective signal presence detection method. Its principle is based on monitoring the power of the received signal and comparing it with a preset threshold to determine whether there is an authorized signal in the frequency band. But when the signal environment is complex, other detection methods need to be used to improve detection performance.

1.2 MATLAB core program

...........................................................................
% AWGN信道的SNR值  
snrdb = -16:0.5:-4; 

% 使用QPSK调制进行测试 
 % PSK调制的调制指数  
M = 4;                
hpsk = comm.PSKModulator('ModulationOrder',M,...
    'BitInput',false,...
    'PhaseOffset',0);  % M-PSK调制器  

% 进行1000次模拟,其中对于每个snr值都会传输一次主要信号。检测到的信号次数将被除以1000,以得到Pd的值。  

nSample = 1000;     % 信号中的样本数  
pde = zeros(1,numel(snrdb)); % Pd的数组  
L = numel(snrdb);
% SNR的循环 
hWait = waitbar(0,'please wait...');
for i = 1:L  % 对于所有的snr值  
    d = 0;              % 检测计数器设置为零  
    % 1000次测试的循环  
    for j = 1:1000      % 1000次模拟  
        infoSignal = randi(M,nSample,1)-1;  % 随机二进制信号(比特数=log2(M))  
        txSignal = step(hpsk,infoSignal);   % M-PSK信号  
        rxSignal = awgn(txSignal,snrdb(i)); % AWGN信道  
        pf = 0.01;     % 假检测的概率  
        snr = 10^(snrdb(i)/20);
        nvar = 1/snr;  % 噪声方差  
        thresh = sqrt(2*nSample*nvar^4)*qfuncinv(pf)+nSample*nvar^2; % 阈值  
        energy = sum(abs(rxSignal).^2);     % 信号的能量 
        if energy > thresh % 如果能量大于阈值,则信号存在  
            d = d+1;
        end
    end
    pde(i) = d/1000; % 1000次模拟的平均值  
    waitbar(i/L,hWait);
end
close(hWait);
% 绘制结果(SNR Vs Pd)  
figure()
plot(snrdb,pde,'b');
xlabel('SNR (dB)');
ylabel('P_d');
title('Energy Detection');
grid on;

%%
displayEndOfDemoMessage(mfilename)
up2205

1.3 Simulation results

Guess you like

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