# How to create a transfer function system model from code with given parameters?

5 views (last 30 days)
Bill Tubbs on 4 Feb 2020
Answered: Star Strider on 4 Feb 2020
I want to replicate a transfer function system model I created with tfest in code.
Here is the model I want to replicate.
>> tf21 = tfest(data_est,2,1,'Ts',1)
tf21 =
From input "u1" to output "y1":
0.9614 z^-1
----------------------------
1 - 1.663 z^-1 + 0.8313 z^-2
Name: tf21
Sample time: 1 seconds
Discrete-time identified transfer function.
Parameterization:
Number of poles: 2 Number of zeros: 1
Number of free coefficients: 3
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "data_est".
Fit to estimation data: 84.81%
FPE: 1.025, MSE: 1.013
>> tf21.Numerator
ans =
0 0.9614
>> tf21.Denominator
ans =
1.0000 -1.6634 0.8313
Here's what I tried:
>> numerator = [0 0.9614];
>> denominator = [1.0000 -1.6634 0.8313];
>> tf_si = tf(numerator,denominator,'ts',1)
tfsi =
0.9614
----------------------
z^2 - 1.663 z + 0.8313
Sample time: 1 seconds
Discrete-time transfer function.
This doesn't look right. I need the same function that maps inputs to outputs. How do I set the coefficients for z^-2 and z^-1 on the denominator so they are the same as in the model I am trying to replicate?

Star Strider on 4 Feb 2020
Try this:
numerator = [0 0.9614 0];
denominator = [1.0000 -1.6634 0.8313 0];
tf_si = tf(numerator,denominator,'ts',1, 'Variable','z^-1')
producing:
tf_si =
0.9614 z^-1
----------------------------
1 - 1.663 z^-1 + 0.8313 z^-2
Sample time: 1 seconds
Discrete-time transfer function.
All the relevant vector elements need to be specified.

R2019b

### Community Treasure Hunt

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

Start Hunting!