资源简介

协作频谱感知源程序,很详细,对比清晰,对初学者有很大的帮助

资源截图

代码片段和文件信息

clear all;clc;
ps = 1;
SNR1 = -8;
T=0.001;
W=5*10^4;
Fs = 2*W;
n = 2*T*W;
snr1 = 10.^(SNR1/10);
pn = (1/snr1)*ps;
count = 5000;
lambda = [500:20:900];
for kk = 1:1:length(lambda);
ff = 0;
dd = 0;
ff1 = 0;
dd1 = 0;
ff2 = 0;
dd2 = 0;
ff3 = 0;
dd3 = 0;
ff4 = 0;
dd4 = 0;
ff5 = 0;
dd5 = 0;
for ii=1:1:count;
t =1:1:n; 
init_phase = 1/6*pi;
sig=2*sin(2*pi*W/Fs*t+init_phase);% 抽样后的信号表达式
noi1 = randn(1n);
noi1 = sqrt(1/snr1)*noi1;
rec1 = noi1 + sig;
noi2 = randn(1n);
noi2 = sqrt(1/snr1)*noi2;
rec2 = noi2 + sig;
noi3 = randn(1n);
noi3 = sqrt(1/snr1)*noi3;
rec3 = noi3 + sig;
noi4 = randn(1n);
noi4 = sqrt(1/snr1)*noi4;
rec4 = noi4 + sig;
noi5 = randn(1n);
noi5 = sqrt(1/snr1)*noi5;
rec5 = noi5 + sig;
noi6 = randn(1n);
noi6 = sqrt(1/snr1)*noi5;
rec6 = noi6 + sig;

sum0_1 = dot(noi1noi1);%求噪声的能量,dot求两矩阵的内积
sum0_2 = dot(noi2noi2);
sum0_3 = dot(noi3noi3);
sum0_4 = dot(noi4noi4);
sum0_5 = dot(noi5noi5);
sum0_6 = dot(noi6noi6);
sum1_1 = dot(rec1rec1);
sum1_2 = dot(rec2rec2);
sum1_3 = dot(rec3rec3);
sum1_4 = dot(rec4rec4);
sum1_5 = dot(rec5rec5);
sum1_6 = dot(rec6rec6);
%单用户能量检测判决
if (sum0_1 > lambda(kk));
ff = ff+1;
end
if (sum1_1 > lambda(kk));
dd = dd+1;
end
if (sum0_2 > lambda(kk));
ff1 = ff1+1;
end
if (sum1_2 > lambda(kk));
dd1 = dd1+1;
end 
if (sum0_3 > lambda(kk));
ff2 = ff2+1;
end
if (sum1_3 > lambda(kk));
dd2 = dd2+1;
end
if (sum0_4 > lambda(kk));
ff3 = ff3+1;
end
if (sum1_4 > lambda(kk));
dd3 = dd3+1;
end
if (sum0_5 > lambda(kk));
ff4 = ff4+1;
end
if (sum1_5 > lambda(kk));
dd4 = dd4+1;
end 
if (sum0_6 > lambda(kk));
ff5 = ff5+1;
end
if (sum1_6 > lambda(kk));
dd5 = dd5+1;
end
end
pd_1(kk) = dd/count;
pf_1(kk) = ff/count;
pd_2(kk) = dd1/count;
pf_2(kk) = ff1/count;
pd_3(kk) = dd2/count;
pf_3(kk) = ff2/count;
pd_4(kk) = dd3/count;
pf_4(kk) = ff3/count;
pd_5(kk) = dd4/count;
pf_5(kk) = ff4/count;
pd_6(kk) = dd5/count;
pf_6(kk) = ff5/count;

pd_7(kk)=pd_1(kk)*pd_2(kk)*pd_3(kk)*pd_4(kk);%*pd_5(kk)*pd_6(kk);
pf_7(kk)=pf_1(kk)*pf_2(kk)*pf_3(kk)*pf_4(kk);%*pf_5(kk)*pf_6(kk);
pd_8(kk)=1-(1-pd_1(kk))*(1-pd_2(kk))*(1-pd_3(kk))*(1-pd_4(kk));%*(1-pd_6(kk));
pf_8(kk)=1-(1-pf_1(kk))*(1-pf_2(kk))*(1-pf_3(kk))*(1-pf_4(kk));%*(1-pf_5(kk))*(1-pf_6(kk));
pd_9(kk)=1-(1-pd_1(kk)*pd_2(kk))*(1-pd_3(kk)*pd_4(kk));%簇头采用and准则融合,信息融合中心采用or准则融合
pf_9(kk)=1-(1-pf_1(kk)*pf_2(kk))*(1-pf_3(kk)*pf_4(kk));

end
plot(pf_7pd_7‘-o‘pf_8pd_8‘-s‘pf_9pd_9‘-*‘);
hold on;
grid on;
xlabel(‘False alarm probability P_{Fa}‘);
ylabel(‘Detection probability P_{d}‘);
legend(‘and理论检测 4用户 SNR=-8dB‘‘or理论检测 4用户 SNR=-8dB‘‘分簇理论检测 4用户 SNR=-8dB‘);
grid on;
hold on;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2770  2014-10-22 16:12  zizuopinpuganzhi.m

评论

共有 条评论