Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimate transfer function from input output data

I have a two-column matrix of data obtained from NI-DAQ. The first column is the output data of a motor-generator set (with driver) and the second column is the input data (square wave). I want to find the transfer function using tfest without Simulink. Is it possible? I have System Identification Toolbox.

How can I attach a .mat file to this post? My data on gist https://gist.github.com/anonymous/6484844

like image 784
Matt1993 Avatar asked Sep 08 '13 13:09

Matt1993


1 Answers

You already got the right idea, I don't know where you got stucked. Here is the code which solves your problem, I tested it, its works fine. Be aware that a simpler input probably gets you better results, that means for example a single step instead of a square wave.

% 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)

Edit: the output for number of poles 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

Edit#2: in your previous question you were asking whether it would be better to use idfrd or iddata - but do you actually have the frequency response data? I actually don't think it should make a big difference, if you choose the number of poles high enough. Just try out what it's working better for you. The workaround is the same.

like image 136
Robert Seifert Avatar answered Sep 19 '22 17:09

Robert Seifert