?? tiaopinxinhao.m
字號:
%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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -