tiaopinxinhao.m

来自「调频信号对抗不同频率干扰和不同形式的噪声的分析」· M 代码 · 共 74 行

M
74
字号
%TIAOPIN
clf;
f1=10000;
f2=15000;
f3=20000;
f4=25000;
N=512;
n=0N-1;
fs=100000;
Ts=1fs;
%Signal without Noise
n1=0127;
n2=128255;
n3=256383;
n4=384511;
x1=cos(2pif1Tsn1);
x2=cos(2pif2Tsn2);
x3=cos(2pif3Tsn3);
x4=cos(2pif4Tsn4);
x=[x1,x2,x3,x4];
y=fft(x,N);
mag=abs(y);
f=(0length(y)-1)'fslength(y);
subplot(211)
plot(x);
xlabel('N');
ylabel('x');
title('Original Signal')
grid   %生成原始信号

subplot(211);
plot(f(1N2),mag(1N2));
xlabel('Frequency(Hz)');
ylabel('Magnitude');
title('Without Noise')
grid    %生成频谱


x=x+0.3randn(1,length(n));
y=fft(x,N);
mag=abs(y);
f=(0length(y)-1)'fslength(y);
subplot(211)
plot(x);
xlabel('N');
ylabel('x');
title('Signal with noise')
grid       %加了高斯噪声的信号

subplot(211);
plot(f(1N2),mag(1N2));
xlabel('Frequency(Hz)');
ylabel('Magnitude');
title('With Noise')
grid           %加了高斯噪声的信号的频谱

x=x+0.3rand (1,length(n));
y=fft(x,N);
mag=abs(y);
f=(0length(y)-1)'fslength(y);
subplot(211)
plot(x);
xlabel('N');
ylabel('x');
title('Signal with noise')
grid       %加了均匀噪声的信号

subplot(211);
plot(f(1N2),mag(1N2));
xlabel('Frequency(Hz)');
ylabel('Magnitude');
title('With Noise')
grid           %加了均匀噪声的信号的频谱

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?