Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2014-03-04
帖子: 1
声望力: 0 ![]() |
![]()
各位好 小弟初學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}') //*********************************************** 可以用來顯示頻譜 結果如下 ![]() 由於想了解示波器抓取訊號的頻譜 把程式改成 //*********************************************** fs = 1000000; % Sample 改為1M取樣 x = scope(:,2); % 讀取示波器取樣的資料 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}') //*********************************************** 結果輸出變成這樣 完全看不到頻譜 ![]() 如果直接將資料用時域顯示如下 是有資料的 ![]() 想請問應該是那邊的問題 應該如何解決呢 謝謝 |
![]() |
![]() |