📄 snrtest.m
字号:
clear all
N=8*1024;
fs=12e3;
fc=1e3;
SNR=-20;
sigma=sqrt(10^(-SNR/10));
t=[0:1/fs:1];
f=[-(N/2)+1:N/2]*fs/N;
x=cos(2*pi*fc*t);
n=sigma*randn(1,length(t));
signal=x+n;
figure(1)
subplot(321);plot(t,x);
subplot(323);plot(t,n);
subplot(325);plot(t,signal);
subplot(322);plot(f,abs(fftshift(fft(x,N))));
axis tight
subplot(324);plot(f,abs(fftshift(fft(n,N))));
axis tight
subplot(326);plot(f,abs(fftshift(fft(signal,N))));
axis tight
fftsig = abs(fftshift(fft(signal,N)));
target=[];
CA=40;
CFAR=[zeros(1,CA+1) fftsig zeros(1,CA+1)];
test=[];
T=3;
M=mean([CFAR(1:CA) CFAR(CA+2:2*CA+2)]);
for i=CA+2:N
test(i)=M*T;
target(i)=(CFAR(i)>M*T);
M=M-CFAR(i-1-CA)/(2*CA)+CFAR(i+1+CA)/(2*CA);
end
figure(2)
subplot(311);plot(fftsig)
subplot(312);plot(test)
subplot(313);plot(target)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -