资源简介:
MATLAB程序下载——一基于MATLAB的无线麦克风阵列的定位。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part74设备(无线麦克风)检测 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
echo on;
connections1=[1 0 1 0 0 ];
connections2=[1 1 1 0 1 ];
gold_seq=PN_1(connections1,connections2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AWGN noise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
val=0.5;
%for snr=0:val:20
for snr=0:val:20
col=(snr+val)/val; % 数组长度
Ta(col)=0; % 加权阈值
Tb(col)=0; % 自适应双阈值
Tc(col)=0; % 自适应单阈值
Td(col)=0; % 固定阈值
% 检测概率
Fa(col)=0; % 加权阈值
Fb(col)=0; % 自适应双阈值
Fc(col)=0; % 自适应单阈值
Fd(col)=0; % 固定阈值
% 漏检概率
Ea(col)=0; % 加权阈值
Eb(col)=0; % 自适应双阈值
Ec(col)=0; % 自适应单阈值
Ed(col)=0; % 固定阈值
for m=1:1:10
clc% 仿真次数
to=0.2; % 接收信号的持续时间
[R,r] = wireless_microphone(to); % 待感知信号
signal_power = 6225.6; % 信号功率
SIGMA=sqrt(6225.6/10^(0.1*snr));
noise = zeros(1,2048);
MU = zeros(1,2048);
noise = normrnd(MU,SIGMA); % 产生AWGN
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% transmitted signal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 假设主用户随机占用信道
for j=1:1:8 % 改变伪随机序列长度,随机改变主用户的占用情况
for k=1:1:8
if (gold_seq(j,k)==1)
xx(1,(length(r)*(k-1)+1):length(r)*k)=r; % 伪随机码为1,主用户占用信道;
else
xx(1,(length(r)*(k-1)+1):length(r)*k)=r; % 伪随机码为0,主用户未占用信道;只有存在噪声
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Muti-cycles detection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nn=noise(1,1:2048);
rr=r(1,1:2048);
S=40; % 循环周期数S,可改为 20,40,50
[l_noise,threshold]=estimate(nn,S);
l_noise=abs(l_noise); % 噪声估计值
[l_signal,threshold]=estimate(rr,S);
l_signal=abs(l_signal); % 信号估计值
for ii=1:8
rr(1,1:2048)= xx(1,(2048*(ii-1)+1):2048*ii); % 每 0.2s 就感知一次信道,进行多周期循环检测
[ll_signal,threshold]=estimate(rr,S);
ll(ii,m)=abs(ll_signal);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 计算自适应阈值 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% `
Pfa=0.3; % 虚警概率可改:0.05,0.1,0.2,0.3
aa=sqrt(2*log10(1./Pfa));
th=l_noise*aa;
adap_thres(m)=th;
%m=m+1;
end
th2=mean(l_noise(1,:));
th3=mean(ll_signal(1,:));
snr_avg=(th3.^2)/(th2.^2);
FT=0.3; % 指数加权因子FT可改为 0.1,0.3,0.9,1.2
th4=threshold*(sqrt(snr_avg)/th3).^FT;
K=0.2; % 乘性因子K可改为 0.01,0.03,0.1,0.2
th6(1,:)=K*l_noise(1,:)/aa;
ouyany=5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 判决 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[FA,EA,TA]=decisionv(ll,th4,gold_seq); % 加权阈值的判决
[FB,EB,TB]=decisionv(ll,th6,gold_seq); % 自适应双阈值的判决
[FC,EC,TC]=decisionv(ll,adap_thres,gold_seq); % 自适应单阈值的判决
[FD,ED,TD]=decisionv(ll,threshold,gold_seq); % 固定阈值的判决
ouyany=4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 统计判决结果 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 虚警概率
Ta(col)=TA/20*8; % 加权阈值
Tb(col)=TB/20*8; % 自适应双阈值
Tc(col)=TC/20*8; % 自适应单阈值
Td(col)=TD/20*8; % 固定阈值
% 检测概率
Fa(col)=FA/20*8; % 加权阈值
Fb(col)=FB/20*8; % 自适应双阈值
Fc(col)=FC/20*8; % 自适应单阈值
Fd(col)=FD/20*8; % 固定阈值
% 漏检概率
Ea(col)=EA/20*8; % 加权阈值
Eb(col)=EB/20*8; % 自适应双阈值
Ec(col)=EC/20*8; % 自适应单阈值
Ed(col)=ED/20*8; % 固定阈值
end
[Fa1]=averge(Fa);
[Fb1]=averge(Fb);
[Fc1]=averge(Fc);
[Fd1]=averge(Fd);
[Ea1]=averge(Ea);
[Eb1]=averge(Eb);
[Ec1]=averge(Ec);
[Ed1]=averge(Ed);
[Ta1]=averge(Ta);
[Tb1]=averge(Tb);
[Tc1]=averge(Tc);
[Td1]=averge(Td);
Fa1=sort(Fa1);
Fb1=sort(Fb1);
Fc1=sort(Fc1);
Fd1=sort(Fd1);
Ta1=sort(Ta1);
Tb1=sort(Tb1);
Tc1=sort(Tc1);
Td1=sort(Td1);
Ea1=sort(Ea1);
Eb1=sort(Eb1);
Ec1=sort(Ec1);
Ed1=sort(Ed1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ed_maximum=max(Ed(:));
for n=1:2:41
tao=log(1-Td(n))/log(Ed(n));
Ni(n)=log((1-Fd(n))/Fd(n))*(tao/((((Ed_maximum*((1-Fd(n))^(-1))-1)^(-1))*(tao))-tao)); % 每种SNR下需要实际频谱感知的次数
Nj(n)=round(abs(Ni(n)));
end
figure;
plot(Nj,’r-*’);
xlabel(‘SNR’);
ylabel(‘感知次数’);
title(‘感知次数’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot detection picture %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
snr=0:1:20;
k=1:2:41;
plot(snr,Fa1(k),’-ro’,snr,Fb1(k),’–k*’,snr,Fc1(k),’-cd’,snr,Fd1(k),’b+-‘)
legend(‘(1)自适应加权阈值’,'(2)自适应双门限阈值’,'(3)自适应单门限阈值’,'(4)固定阈值’)
grid on ;
xlabel(‘SNR/db’)
ylabel(‘Pd’)
title(‘无线麦克风信号正确检测概率图’);
figure
subplot(2,1,1)
plot(xx);
xlabel(‘时间[s]’);
ylabel(‘幅度[V]’);
title(‘间隙发送无线麦克风信号’);
subplot(2,1,2)
bar(ll);
xlabel(‘时间[s]’);
ylabel(‘检测估计值’);
title(‘检测估计值图’);
figure
snr=0:1:20;
k=1:2:41;
plot(snr,Ta1(k),’-ro’,snr,Tb1(k),’–k*’,snr,Tc1(k),’-cd’,snr,Td1(k),’b+-‘)
legend(‘(1)自适应加权阈值’,'(2)自适应双门限阈值’,'(3)自适应单门限阈值’,'(4)固定阈值’)
grid on ;
xlabel(‘SNR/db’)
ylabel(‘Pf’)
title(‘无线麦克风信号虚警概率图’);
figure
snr=0:1:20;
k=1:2:41;
plot(snr,Ea1(k),’-ro’,snr,Eb1(k),’–k*’,snr,Ec1(k),’-cd’,snr,Ed1(k),’b+-‘)
legend(‘(1)自适应加权阈值’,'(2)自适应双门限阈值’,'(3)自适应单门限阈值’,'(4)固定阈值’)
grid on ;
xlabel(‘SNR/db’)
ylabel(‘Pm’)
title(‘无线麦克风信号漏检概率图’);
下载:
今天的文章麦克风定位matlab,MATLAB代做|FPGA代做|simulink代做–无线麦克风阵列的定位分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/32758.html