根据输入输出数据估算传递函数

时间:2013-09-08 13:50:13

标签: matlab signal-processing nidaqmx

我有一个从NI-DAQ获得的两列数据矩阵。第一列是电动机 - 发电机组(带驱动器)的输出数据,第二列是输入数据(方波)。我想在没有Simulink的情况下使用tfest找到传递函数。可能吗?我有系统识别工具箱

如何将.mat文件附加到此帖子?关于要点https://gist.github.com/anonymous/6484844

的数据

1 个答案:

答案 0 :(得分:7)

你已经有了正确的想法,我不知道你被困在哪里。 这是解决你的问题的代码,我测试了它,它的工作正常。请注意,更简单的输入可能会让您获得更好的结果,这意味着例如单步而不是方波。

% load your data (text file with your two columns)
load data.txt;

% sample index, reducing of input to get single step instead of square wave
x = 1:1:length(data);
data(x > 2900,:)=[];
x(x > 2900)=[];

% plot data
figure(1)
plot(x,data(:,1)); hold on
plot(x,data(:,2)); hold off

% prepare data for tftest, 100 is a random chosen sampling time
tfdata = iddata(data(:,1),data(:,2),100);

% estimate system, factor 5 -> number of poles (variable as desired)
sys = tfest(tfdata,5);

% plot step response (factor 5 comes from input)
figure(2)
step(5*sys)

编辑:极数np = 5的输出:

sys =


  From input "u1" to output "y1":
    -3.337e-05 s^4 + 1.326e-07 s^3 + 1.639e-11 s^2 + 1.221e-14 s + 1.064e-19
  ----------------------------------------------------------------------------
  s^5 + 0.005287 s^4 + 1.516e-06 s^3 + 4.517e-10 s^2 + 2.896e-14 s + 2.037e-19

编辑#2:您在上一个问题中询问使用idfrdiddata是否更好 - 但您实际上是否有频率响应数据?如果你选择足够高的杆数,我实际上并不认为它应该有很大的不同。试试看它对你有用的效果。解决方法是一样的。