【问题标题】:How to find the bode plot of a matrix in matlab?如何在matlab中找到矩阵的波特图?
【发布时间】:2013-10-17 18:39:31
【问题描述】:

我正在尝试使用 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 步。

【问题讨论】:

  • fft_ratio 作为 1001x1001 矩阵;听起来对吗?
  • 如果这是 mathworks 波特函数,它适用于系统对象,而不是矩阵。 mathworks.com/help/ident/ref/bode.html
  • 除第一列外,其他列均为0 + 0i。所以我猜这并不重要。我看过 mathworks.in/help/ident/ref/bode.html 页面。但是,我无法生成系统。
  • 根本不要使用那个功能,看我的回答。

标签: matlab


【解决方案1】:

使用element-wise divide,而不是矩阵除法,并使用 plot 函数绘图。要生成类似于bode function 中所示的绘图,您可以使用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))

【讨论】:

  • 好的,但是如何从中找到传递函数?
  • 我不确定什么是“频率响应方法”,但曲线拟合是曲线拟合,不管曲线的性质如何,有很多方法可以做到。
猜你喜欢
  • 2020-06-19
  • 1970-01-01
  • 2014-01-21
  • 1970-01-01
  • 2015-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多