MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB数学相关] Matlab (https://www.labfans.com/bbs/showthread.php?t=20644)

whatdavid 2014-03-04 22:41

Matlab
 
各位好 小弟初學Matlab 目前有一個問題想請教大家
目前想了解FFT的使用 在網路上抓了一個例程
//***********************************************
fs = 100; % Sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 sec sample
x = (1.3)*sin(2*pi*15*t) ... % 15 Hz component
+ (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component
+ (2.5)*randn(size(t)); % Gaussian noise;
m = length(x); % Window length
n = pow2(nextpow2(m)); % Transform length
y = fft(x,n); % DFT
f = (0:n-1)*(fs/n); % Frequency range
power = y.*conj(y)/n; % Power of the DFT
plot(f,power)
xlabel('Frequency (Hz)')
ylabel('Power')
title('{\bf Periodogram}')
//***********************************************
可以用來顯示頻譜
結果如下
[IMG]http://www.kingway-tech.com/Temp/example.jpg[/IMG]

由於想了解示波器抓取訊號的頻譜
把程式改成
//***********************************************
fs = 1000000; % Sample [COLOR="Red"]改為1M取樣[/COLOR]
x = scope(:,2); % [COLOR="Red"]讀取示波器取樣的資料[/COLOR]
m = length(x); % Window length
n = pow2(nextpow2(m)); % Transform length
y = fft(x,n); % DFT
f = (0:n-1)*(fs/n); % Frequency range
power = y.*conj(y)/n; % Power of the DFT
plot(f,power)
xlabel('Frequency (Hz)')
ylabel('Power')
title('{\bf Periodogram}')
//***********************************************
結果輸出變成這樣 完全看不到頻譜
[IMG]http://www.kingway-tech.com/Temp/Scope.jpg[/IMG]
如果直接將資料用時域顯示如下 是有資料的
[IMG]http://www.kingway-tech.com/Temp/Raw_Data.jpg[/IMG]
想請問應該是那邊的問題 應該如何解決呢 謝謝


所有时间均为北京时间。现在的时间是 13:57

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.