?? exa8_26.m
字號:
t = 0:0.001:0.6;
%產(chǎn)生原始信號
x = sin(2*pi*50*t)+sin(2*pi*120*t);
%對原始信號加入0平均的隨機噪音干擾
subplot(2,2,1)
plot(1000*t(1:50),x(1:50))
title('(a)原始信號')
ylabel('u /v')
xlabel('t /ms')
yt = 2*randn(size(t));
subplot(2,2,2)
plot(1000*t(1:50),yt(1:50))
title('(b)零均值隨機噪聲')
ylabel('u /v')
xlabel('t /ms')
y = x + yt;
%繪制干擾后的信號頻譜圖
subplot(2,2,3)
plot(1000*t(1:50),y(1:50))
title('(c)零均值隨機噪聲干擾的信號')
ylabel('u /v')
xlabel('t /ms')
%運行512點得快速傅立葉變換
Y = fft(y,512);
Pyy = Y.* conj(Y) / 512;
%獲得開始的257個數(shù)據(jù)點,其余的225個點不用
f = 1000*(0:256)/512;
%繪制頻譜圖
subplot(2,2,4)
plot(f,Pyy(1:257))
title('(d)fft變換頻譜')
ylabel('u /v')
xlabel('f /Hz')
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -