[討論] FFT與filter問題

看板MATLAB作者 (momo)時間14年前 (2011/11/19 16:48), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
是說在下不是很熟悉MATLAB, 經過爬文及看書後還是遇到了瓶頸, 想請教一下各位...如果太白目請鞭小力一點>"< 有一筆5000點的數據,取樣頻率為50Hz, 為了做濾波,想先看FFT的頻域圖再做設計。 程式碼如下:(有點長) ------------------------------------------------ clear all;clc; load mo.xls;data = mo; %讀取檔案 load_cell = data(1:4999,2); %取第二行的資料 N = length(load_cell); %資料數量 Fs = 50; %取樣頻率 Ts = 1/Fs; %取樣時間間隔 time = (0:N-1)*Ts; %時域的時間軸刻度 subplot(1,5,1); plot(time,load_cell);axis square axis([-inf inf 0 1]); title('time-domain (all data)'); xlabel('time (s)');ylabel('load cell (N)'); freqstep = Fs/N; %頻域解析度 freq = freqstep*(-N/2:N/2-1); %頻域的頻率軸刻度 power = fft(load_cell); subplot(1,5,2); plot(freq,power);axis square title('frequency-domain (all data)'); xlabel('frequency (Hz)');ylabel('power'); y_test = ifft(power); %再轉換回來看會不會一樣 subplot(1,5,3); plot(time,y_test);axis square axis([-inf inf 0 1]); title('time-domain (all data-reverse)'); xlabel('time (s)');ylabel('load cell (N)'); [b,a] = butter(5,[],'band'); %設計一個filter y_new = filter(b,a,load_cell); subplot(1,5,5); plot(time,y_new);axis square axis([-inf inf 0 1]); ------------------------------------------------ 目前只寫到這裡,但發現有幾個地方不是很清楚... 1. 頻域軸刻度的決定 2. butter中bandpass的頻率決定 (因為前面的FFT出圖看不出來雜訊頻率...而且我覺得他怪怪的...) 麻煩各位幫我看一下,感謝>"< 如果有必要,可以直接用MSN跟我說... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.148.26
文章代碼(AID): #1Ensrjrk (MATLAB)
文章代碼(AID): #1Ensrjrk (MATLAB)