Problems using 'tfest' for generating transfer function

Hello guys...
I am trying to find a transfer function for my signal, that matches with the moving average block of my signal. I used tfest to recreate the signal using the generated coefficients. However, the accuracy is very low at 2%. I am wondering how to increase it, or am I doing something wrong.
In another case, to verify whether the function works, I tried with tf = 1/(s+1), generated the signals, used 'tfest' to get the transfer function, I got 0.1404/(s+0.1998) , which is way-way off.
let me know what you think of this.
Have a nice day..
data_0= iddata(T_avg_mean,T_pedal,0.01);
>> tf_estimated = tfest(data_0,2)
tf_estimated =
From input "u1" to output "y1":
-0.0188 s + 0.005945
--------------------------
s^2 + 7.891e-06 s + 0.4232
Continuous-time identified transfer function.
Parameterization:
Number of poles: 2 Number of zeros: 1
Number of free coefficients: 4
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "data_0".
Fit to estimation data: 2.051%
FPE: 128.3, MSE: 128.3

10 Comments

hello
can you share the data you used for tfest ?
Heyy,, thanks for your reply.
I have just attached the simulink model and data in a zip file in the main question here...
have a nice day...
hello again
the simulink file I could not open it causeI run R2020b
maybe I simply need both input and output data but your T_in timeseries has only one data
Ah okay..sorry for that.
The model is easy. I am just running a moving average block with sliding window (window length 200, overlap 199). I sent this signal to workspace.
I want to find a transfer function that matches with this, using "tfest".
to cross check, i used another block 1/s+1.
I have shared a snapshot of the model for your better understanding. also, i have saved the model in 2020b. you can also find the output variables in the zip file.
please let me know in case of anything.
Heyy.. I hope you are doing well..Sorry, I got stuck with some other deadline. I needed some time to understand your solution.
Thanks for sharing the functions and plots. It is really helpful.
I looked into your code, and what i understand is that Txy is the variable for transfer function estimate. When i checked it is a vector of complex doubles (8193x1). Then using invfreqnz we can find the numerator and Denominator for an estimated transfer function model. the variables B and A contains the coefficients of num and den respectively.
Now, i tried this for tf_1 , i.e. a transfer function (1/(s+1)), I set orders NB=0 and NA=1. I got B=2.37e-08 and A = [1 -0.99]. also the bode plots did not match.
Q : Does it make a transfer function (0/s-1) approximatly?. in which order should i read this coefficients?
next, I set orders NB=1 and NA=2; i got B=[3.18e-08 0.0099] and A = [1 -0.99 5.62e-06]. This time the bode plots did match.
Q : Does it make a transfer function (0.01/s-1) approximatly?
I am trying to get B as 1 and A as [1 1] finally.
After that, I want to try this same model with the signal generated with the mean block.. what i see now is , it is closely matching it in BODE with NB=200 and NA=100.. around 4 or 5 as orders, bode does not match.
Q : do you think making a small order (max. 4th , 5th) with same/similar response (even if it does not match exactly in Bode plots) is possible?
(Currently , I solved the problem using trial-error. like for filtering purpose, a 200 sample averaging closely matches with a tf 1/s+1..But i am trying to find a better solution )
I hope you understand what i am trying to do. Maybe some suggestions to tweak these parameters would be very helpful.
Thanks a lot for your time and for sharing the codes.
Have a nice day ahead.
If you can post the solution in the Answer column, i can accept it. for formalities maybe...
hello again
I put the comment in the answer section as you kindly suggested
now I don't understand your problems with my scripts ...remember that the identified transfer functions are discrete models so the B and A are coefficients you cannot compare to a continuous time model like (1/(s+1))
you have to convert the identified discrete models to continuous time model with d2c function (I didn't make it in my script but you can easily add that code)
I dont have any problems... The process is exactly as per my requirement...But the values were not satisfactory.. that is why i made further comments.. Thanks a lot for your help again..
Have a nice day...

Sign in to comment.

 Accepted Answer

Mathieu NOE
Mathieu NOE on 8 Nov 2022
Moved: Mathieu NOE on 17 Nov 2022
hello again
here a bunch of files to post process your data
I don't have the ID toolbox but I have the Signal Processing Tbx ( I use invfreqz to get the num/den model from a frequency domain model (cf Bode plot)
the Bode plot and coherence plot is obtained with my function mytfe_and_coh.m (also attached)
coherence plot is also good to have to make sure the input signal (x) has energy distributed accross the entire frequency range (otherwise the results may be inaccurate in frequency domain that has been poorly excited);
I don't put all the codes here in the window otherwise it's gonna be very clutered
see the attachements and maybe that can help you
see identified models Bode plots are precisely matchind the tfe Bode plot
NB : I identified the models in the discrete domain, use d2cm to get back to continuous if needed

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!