我检测住用户信号为单音信号,就是一个正弦信号%匹配滤波检测clear all;clc;Sim_Times=5000; %Monter-Carlo times m=5; W=1; Fs=4; N =Fs*m; %此处还是满足采样定理snr_avgdB =-5; snr_avg = power(10,snr_avgdB/10); Pf=0:0.02:1; for i=1:length(Pf) Over_Num_awgn(i) = 0; %Monter-Carlo simualtion for kk = 1:Sim_Times t = (kk-1)*N+1:kk*N; A=10; F0=W; init_phase = 1/6*pi; Single1=A*sin(2*pi*F0/Fs*t + init_phase); %awgn channels 噪声和信号 Noise =0+ sqrt(1) * randn(1,N);%产生均值为0,方差为1的高斯噪声 singal=Single1+Noise %Detection Process 检测过程 a1=singal; a2=Single1; e=sum(a1.*a2); f=sum(a1.^2); accum_Num_awgn(i) = e; lim(i)=qfuncinv(Pf(i))*sqrt(f);%给定的pf反推的lim lim1(i)=log(lim(i))+0.5*f; if accum_Num_awgn(i)>lim1(i) Over_Num_awgn (i)= Over_Num_awgn(i) +1; end end %Calculate Pd and Pm for each scenario Pd_sim_awgn = Over_Num_awgn / Sim_Times; end%Theory results according Digham and GhasemiPd_theory_awgn = qfunc(qfuncinv(Pf)-sqrt(snr_avg *N)); %pd理论值 Pm_sim_awgn =1-Pd_sim_awgn %实际pmPm_theory_awgn = 1- Pd_theory_awgn;%理论pmloglog(Pf,Pm_sim_awgn,'*b')hold onloglog(Pf,Pm_theory_awgn,'-r'); grid onaxis([0.0001,1,0.0001,1]);xlabel('虚警概率Pf');ylabel('漏检概率Pm');legend('仿真值','理论值');title('匹配滤波器检测ROC曲线图')仿真后,理论曲线能出来但是仿真曲线出不来求大神找下错误 |
|
|
|
|
共 1 个关于本帖的回复 最后回复于 2015-1-15 17:08