✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

⛄ 内容介绍

Blind signal detection is very important in various applications such as cognitive radio, spectrum surveillance, and eavesdropping. This gets trickier when one needs to deal with burst signals (as opposed to continuously transmitted signals) in non-cooperative environments. Here, existing methods for signal detection are studied and developed to use for burst detection.For the special case of downlink time division multiple access (TDMA) burst transmission, performances of these detection methods are improved by proposing a blind synchronisation algorithm which is applied to the output result of detection algorithms. The results of Monte–Carlo simulations demonstrate the performance of the proposed detection and synchronisation algorithms.

基于Matlab实现突发信号位置检测算法ERD_ide

⛄ 完整代码

clc;

clear;

close all

%% 产生噪声与信号源

code_fre = 1e6; %信号载波频率

fs = 10e6; %采样频率

sample_t = 1/fs;%采样间隔

length_all = 400;%仿真信号总长度(符号数量)

noise_std = 1;%噪声方差

%snr = 0;%信噪比

burst_length = 30; %每个突发信号的长度

Ncoh = (fs / code_fre)*burst_length;%一个积分清除时间内的采样点数

dot_length = [1:Ncoh];

burst_num = 5; %突发信号个数

burst_err = zeros(100,10);

guard_err = zeros(100,10);

for t = 1:100

    for l = 1:10

        snr = -1+l;

        position = zeros(1,burst_num); 

        position(1) = 10+randperm(50,1);%返回1个[1,50]的数

        for i=2:burst_num

            position(i) = position(i-1)+30+randperm(50,1);%出现信号的起始位置

        end

        

        burst_code = zeros(burst_num,burst_length);

        burst_code_sampled = zeros(burst_num,burst_length*fs/code_fre);

        for i = 1:burst_num

            burst_code(i,:) = -2*randi([0,1],[1,burst_length])+1;

            sampled = repmat(burst_code(i,:),fs/code_fre,1);%将burst_code(i,:)复制

            burst_code_sampled(i,:) = reshape(sampled,1,burst_length*fs/code_fre);

        end

        noise = noise_std*rand(1,length_all*fs/code_fre);%噪声

        carrier = cos(2*pi*(code_fre)*dot_length*sample_t);%初始载波信号

        err = zeros(1,13);

     

        signal_amplitude = sqrt(10^(snr/10)*(noise_std^2*2));%根据信噪比扩大幅值


        signal_burst = zeros(burst_num,burst_length*fs/code_fre);

        for j=1:burst_num

            signal_burst(j,:) = signal_amplitude*burst_code_sampled(j,:).* carrier;

    

        end

        receive_signal = noise;


        num = length_all*fs/code_fre;

        wdd = zeros(1,num); %记录正确判决结果

        for i=1:burst_num

            receive_signal(position(i)*fs/code_fre:position(i)*fs/code_fre+burst_length*fs/code_fre-1) = signal_burst(i,:)+receive_signal(position(i)*fs/code_fre:position(i)*fs/code_fre+burst_length*fs/code_fre-1);

            wdd(position(i)*fs/code_fre:position(i)*fs/code_fre+burst_length*fs/code_fre-1) = ones(1,burst_length*fs/code_fre);

        end

        receive_signal = receive_signal/(max(abs(receive_signal)));%将输入数据归一化


%% ERD算法

        slide_length = 20;


        ERs = zeros(1,num);

        ERe = zeros(1,num);

        threshold = abs((1+3*10^(snr/10))*0.5);

        for j = slide_length+1:num-slide_length+1

            w1_pos = j;

            w2_pos = j-slide_length;

            w1 = sum(abs(receive_signal(w1_pos:w1_pos+slide_length-1)).^2);

            w2 = sum(abs(receive_signal(w2_pos:w2_pos+slide_length-1)).^2);

            ERs(j) = w1/w2;

            ERe(j) = w2/w1;    

        end


        ERs_threshold = ERs;

        ERe_threshold = ERe;

        for i = 1:num

            if ERs(i)<threshold

                ERs_threshold(i) = 0;

            end

            if ERe(i)<threshold

                ERe_threshold(i) = 0;

            end    

        end

        ERs_new = zeros(1,num);

        ERe_new = zeros(1,num);


%% 检测输出  窗口内取 ERs和ERe的最大值

        for i = slide_length+1:num+1

            [ERs_max,ERs_pos] = max(ERs_threshold(i-slide_length:i-1));

            ERs_threshold(i-slide_length:i-1)=0;

            ERs_threshold(i-slide_length+ERs_pos-1)=ERs_max;

            [ERe_max,ERe_pos] = max(ERe_threshold(i-slide_length:i-1));

            ERe_threshold(i-slide_length:i-1)=0;

            ERe_threshold(i-slide_length+ERe_pos-1)=ERe_max;

        end

        ERs_new = ERs_threshold>0;

        ERe_new = ERe_threshold>0;

        ERs_index = find(ERs_new == 1);

        ERe_index = find(ERe_new == 1);

        wd1 = zeros(1,num);

        burst_data = [];

        for i = 1:length(ERe_index)

            k = length(ERs_index);

            for j=1: k

                if ERs_index(j)<ERe_index(i)

                    burst_data = [burst_data,ERs_index(j)];

                end

            end

        if length(burst_data)~=0

            [burst_min,burst_start] = min(ERe_index(i)-burst_data);

            wd1(burst_data(burst_start):ERe_index(i))=1; % 有信号的地方 标1

            ERs_index(find(ERs_index==burst_data(burst_start)))=[];% 删除

            burst_data = [];

        end

        end


%% 增加滑动窗口长度

slide_length = 100;

num = length_all*fs/code_fre;

ERs = zeros(1,num);

ERe = zeros(1,num);

threshold = abs((1+3*10^(snr/10))*0.5);

for j = slide_length+1:num-slide_length+1

    w1_pos = j;

    w2_pos = j-slide_length;

    w1 = sum(abs(receive_signal(w1_pos:w1_pos+slide_length-1)).^2);

    w2 = sum(abs(receive_signal(w2_pos:w2_pos+slide_length-1)).^2);

    ERs(j) = w1/w2;

    ERe(j) = w2/w1;    

end


ERs_threshold = ERs;

ERe_threshold = ERe;

for i = 1:num

    if ERs(i)<threshold

        ERs_threshold(i) = 0;

    end

    if ERe(i)<threshold

        ERe_threshold(i) = 0;

    end    

end

ERs_new = zeros(1,num);

ERe_new = zeros(1,num);


%% 检测输出

for i = slide_length+1:num+1

    [ERs_max,ERs_pos] = max(ERs_threshold(i-slide_length:i-1));

    ERs_threshold(i-slide_length:i-1)=0;

    ERs_threshold(i-slide_length+ERs_pos-1)=ERs_max;

    [ERe_max,ERe_pos] = max(ERe_threshold(i-slide_length:i-1));

    ERe_threshold(i-slide_length:i-1)=0;

    ERe_threshold(i-slide_length+ERe_pos-1)=ERe_max;

end

ERs_new = ERs_threshold>0;

ERe_new = ERe_threshold>0;

ERs_index = find(ERs_new == 1);

ERe_index = find(ERe_new == 1);

wd2 = zeros(1,num);

burst_data = [];

for i = 1:length(ERe_index)

   k = length(ERs_index);

   for j=1: k

       if ERs_index(j)<ERe_index(i)

           burst_data = [burst_data,ERs_index(j)];

       end

   end

   if length(burst_data)~=0

       [burst_min,burst_start] = min(ERe_index(i)-burst_data);

       wd2(burst_data(burst_start):ERe_index(i))=1;

       ERs_index(find(ERs_index==burst_data(burst_start)))=[];

       burst_data = [];

   end

end

wd = wd1.*wd2; % 综合判决,就是都为1时,即为窗口信号

err(1,l) = sum(wd~=wdd);

burst_err(t,l) = (sum(wdd)-sum(wd&wdd))/sum(wdd);

guard_err(t,l) = (sum(~wdd)- sum(~wd&~wdd))/sum(~wdd);


end

end

X = 0:9;

%Y = mean(burst_err);

plot(X,mean(burst_err),'-O');


hold on;

plot(X,mean(guard_err),'-*')

legend('错误率','虚警率');

title('ERD算法的检测错误率和虚警率');

xlabel('SNR(dB)');

ylabel('概率p');

⛄ 运行结果

基于Matlab实现突发信号位置检测算法ERD_信噪比_02

⛄ 参考文献

[1]赵丽华, 王鹏宇. 基于Matlab的非时域端点检测算法的实现与分析[J]. 科学技术与工程, 2010(35):4.

⛳️ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料