雜訊的頻譜分析的重要意義 頻譜分析的作用

2021-10-12 15:06:35 字數 3272 閱讀 9552

首先補充:

randn()函式用來產生正態分佈的隨機數或矩陣

conj()函式用來求負數的共軛:如果z是乙個復陣列,那麼conj(z) = real(z) - i*imag(z)其中real(z),imag(z)分別代表z的實部和虛部

1.首先看一下頻譜分析下,頻譜影象展現的特徵:

x = sin(2*pi*50*t)的原圖和頻譜圖:

**:1 clear;2 clc;3 t = 0:0.001:0.25;4 x = sin(2*pi*50*t);5 %x = 2*sin(2*pi*50*t+pi);6 %x = sin(2*pi*50*t) + 2*sin(2*pi*140*t);7 %x = sin(100*pi*t)+cos(280*pi*t);8 figure(1);9 plot(t,x);10 xlabel('t'); ylabel('f(t)');11 y =x;12 y = fft(y,256);13 pyy = y.*conj(y)/256; %計算y的模的長度14 f = 1000/256*(0:127);15 figure(2);16 plot(f,pyy(1:128));17 title('power spectral density');18 xlabel('frequency (hz)');

view code

結果圖為:

頻譜圖中,峰值是正好是原函式的週期的頻率。  變下初始相位呢?

x = 2*sin(2*pi*50*t+pi);

**:1 clear;2 clc;3 t = 0:0.001:0.25;4 %x = sin(2*pi*50*t);5 x = 2*sin(2*pi*50*t+pi);6 %x = sin(2*pi*50*t) + 2*sin(2*pi*140*t);7 %x = sin(100*pi*t)+cos(280*pi*t);8 figure(1);9 plot(t,x);10 xlabel('t'); ylabel('f(t)');11 y =x;12 y = fft(y,256);13 pyy = y.*conj(y)/256; %計算y的模的長度14 f = 1000/256*(0:127);15 figure(2);16 plot(f,pyy(1:128));17 title('power spectral density');18 xlabel('frequency (hz)');

view code

結果圖為:

仍然滿足那個結論。那麼組合一下呢?

x = sin(2*pi*50*t) + 2*sin(2*pi*140*t);

**:1 clear;2 clc;3 t = 0:0.001:0.25;4 %x = sin(2*pi*50*t);5 %x = 2*sin(2*pi*50*t+pi);6 x = sin(2*pi*50*t) + 2*sin(2*pi*140*t);7 %x = sin(100*pi*t)+cos(280*pi*t);8 figure(1);9 plot(t,x);10 xlabel('t'); ylabel('f(t)');11 y =x;12 y = fft(y,256);13 pyy = y.*conj(y)/256; %計算y的模的長度14 f = 1000/256*(0:127);15 figure(2);16 plot(f,pyy(1:128));17 title('power spectral density');18 xlabel('frequency (hz)');

view code

結果圖為:

頻譜圖中竟然把50hz和140hz都顯示出來哎,unbelievable!.不行,再試試,換成cos試試?

x = sin(100*pi*t)+cos(280*pi*t);

**:1 clear;2 clc;3 t = 0:0.001:0.25;4 %x = sin(2*pi*50*t);5 %x = 2*sin(2*pi*50*t+pi);6 %x = sin(2*pi*50*t) + 2*sin(2*pi*140*t);7 x = sin(100*pi*t)+cos(280*pi*t);8 figure(1);9 plot(t,x);10 xlabel('t'); ylabel('f(t)');11 y =x;12 y = fft(y,256);13 pyy = y.*conj(y)/256; %計算y的模的長度14 f = 1000/256*(0:127);15 figure(2);16 plot(f,pyy(1:128));17 title('power spectral density');18 xlabel('frequency (hz)');

view code

結果圖為:

也是如此。這下終於可以放心了。原來頻譜圖是這個作用~。

(2)還是有點不放心。如果加上雜訊呢,還能識別出來麼?

先測試下雜訊:

1 clear;2 clc;3 t = 0:0.001:0.25;4 figure(1);5 y = 2*randn(size(t));6 plot(t,y);7 xlabel('t');ylabel('y');8 y = fft(y,256);9 pyy = y.*conj(y)/256; %計算y的模的長度10 f = 1000/256*(0:127);11 figure(2);12 plot(f,pyy(1:128));13 title('power spectral density');14 xlabel('frequency (hz)');

view code

結果圖為:

雜亂無章。。。再測一次試試:

還是雜亂無章,峰值也沒有個確定的值。確定為雜訊無疑了。

好,那麼現在就用你加到上面的正弦函式影象上去!

**:1 clear;2 clc;3 t = 0:0.001:0.25;4 x = sin(100*pi*t)+cos(280*pi*t);5 figure(1);6 plot(t,x);7 xlabel('t'); ylabel('f(t)');8 y = x + 2*randn(size(t));9 figure(2);10 plot(t,y);11 xlabel('t');ylabel('y(t)');12 y = fft(y,256);13 pyy = y.*conj(y)/256; %計算y的模的長度14 f = 1000/256*(0:127);15 figure(3);16 plot(f,pyy(1:128));17 title('power spectral density');18 xlabel('frequency (hz)');

view code

結果圖為:比較下兩圖可以知道,由於受到雜訊干擾。影象幾乎很難分辨出訊號影象。

頻譜分析圖這裡,竟然有兩個突出的峰值:

仔細觀察,竟然就是50hz和140hz。這下好了,合成的訊號用頻譜分析竟然可以清楚的找到原來的正弦訊號~。

咳咳,總結:經過傅利葉變換之後,頻譜圖的確能夠幫助我們分析訊號的成分,便於對訊號進行處理。

兩正弦加一雜訊訊號的頻譜分析

matlab r2016a完全自學一本通 455頁,例14 19,下面的命令對乙個以50hz和120hz為主要成分的訊號進行傅利葉變換。如下 fs 1000 t 1 fs l 1000 t 0 l 1 t x 0.7 sin 2 pi 50 t sin 2 pi 120 t y x 2 randn ...

頻譜分析儀的基本使用

因為專案需要,今天學著使用的一下頻譜分析儀,專案屬於物聯網型別,通訊方式是使用的當前市面上比較火的lora技術 當前市面上常用的兩種低功耗遠距離通訊方案是lora和nb lot 本次使用頻譜分析儀用來測量設計的板子用lora傳送無線資料時候的一些相關引數,主要測試天線傳送資料時候的發射功率 單位 d...

FFT頻譜分析中的幾個誤差

fft在分析頻譜分析的時候,會有下面四個方面的誤差 1 頻譜混疊 奈奎斯特定理已被眾所周知了,所以幾乎所有人的都知道為了不讓頻譜混疊,理論上取樣頻譜大於等於訊號的最高頻率。那和時域上聯絡起來的關係是什麼呢?取樣週期的倒數是頻譜解析度,最高頻率的倒數是取樣週期。設定取樣點數為n,取樣頻率fs,最高頻率...