Info

This question is closed. Reopen it to edit or answer.

Follow-up : Using results from Transfer Function Estimates in System Identification Toolbox

1 view (last 30 days)
Hello, this question is directly linked to this question:
and referring to:
I use the system identification toolbox to find the link between an input and output placed in a iddata structure :
Using ident I load my iddata and I estimate the continuous-time transfer function with 4 poles and 0 zeros. I do not modify any option; initial conditions stay Auto and Initialization method IV. When I display the model output from the system identification window it is really corresponding to what I am looking for:
Next I want to repreduce the same thing in my .m file using these commands:
Options = tfestOptions;
Options.Display = 'on';
tf1 = tfest(DS16, 4, 0, Options)
tf1d = c2d(tf1,ts_ad7190) % convert to discrete
tf1dout = filter(tf1d.num,tf1d.den,DS16.InputData);
figure()
hold on;
plot(x1,DS16.InputData,'LineWidth',1,'color','cyan');
plot(x1,DS16.OutputData,'LineWidth',1,'color','black');
plot(x1,tf1dout,'LineWidth',1,'color','red');
legend('Input signal','desired output','tf1dout filter output','location','southeast');
I get the following result (red):
And it is not what I am looking for. I tryed to add the following initial conditions:
%tf1dout = filter(tf1d.num,tf1d.den,DS16.InputData,filtic(tf1d.num,tf1d.den,[0,0,0]));
but the result is the same.
Also If I use the sim() function the result is the same.
I would like to know what my .m file is missing to be able to have the same nice result that I get in the System identification window.
If my mistake is not obvious I can post .csv file containing DS16 and my .m file. Thank you!
  1 Comment
Jesse Salazar
Jesse Salazar on 22 Jun 2018
Hi Simon,
Try converting to ZPK, then the more stable DF2T first:
% Convert to discrete, then zpk
tf1d = c2d(tf1,ts_ad7190)
[z,p,k] = zpkdata(tf1d,'v');
% Create a digital filter using df2t sos format
Hd = dfilt.df2tsos(zp2sos(z,p,k));
% Now filter, as usual
tf1dout = filter(Hd, DS16.InputData);
Also note that ARM has compatible biquad filter functions for working with the SOS filter created above (but remember that Matlab has inverted 'a' coefficients, and that ARM biquad does not include 0th 'a' term, e.g. for each SOS stage ARM has coeffs like {b0, b1, b2, a1, a2})
I know it's a late response, but figured I'd still post.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!