簡體   English   中英

如何在Matlab中找到矩陣的波特圖?

[英]How to find the bode plot of a matrix in matlab?

我正在嘗試使用FFT方法查找一組輸入輸出數據的系統傳遞函數。 我要遵循的算法如下:

  1. 將輸入數據和輸出數據加載到matlab中。
  2. 對輸入數據和輸出數據進行FFT。
  3. 將輸出FFT除以輸入FFT,然后取幅值。 由於本例的輸入為單位脈沖,因此輸入FFT為1.0。
  4. 將結果繪制為波特圖。
  5. 將生成的Bode'圖視為頻率響應(實際上是頻率響應),並使用頻率響應方法將傳遞函數擬合到計算出的Bode'圖。

我的代碼是:

load testdata.mat; // testdata is a 2 column matrix (1001x2 matrix)

input = fft(signal(:,1)); // FFT of input data (1001x1 complex matrix)

output = fft(signal(:,2)); // FFT of output data (1001x1 complex matrix)

fft_ratio = output/input; // (1001x1001 complex matrix)

fft_ratio_mag = abs(fft_ratio); // (1001x1001 matrix) except column 1, all other    columns have '0' data

bode(fft_ratio_mag(:,1))

我收到以下錯誤:

Error using bode (line 84)
Not enough input arguments.

請指導我如何執行上述算法中的第4步和第5步。

使用逐元素除法 ,而不是矩陣除法,並使用plot函數進行繪圖。 要生成類似於bode 函數中所示的圖,可以使用semilogx進行繪制,但自己進行dB和度轉換:

fft_ratio = output ./ input % note the dot
subplot(2,1,1)
semilogx(20*log10(abs(fft_ratio)))
subplot(2,1,2)
semilogx(plot((180/pi)*angle(fft_ratio))

使用您喜歡的方式生成x軸,我通常使用從0到1的歸一化弧度頻率,即linspace(0,1,length(fft_ratio))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM