How to check if two transfer functions are the same?
20 views (last 30 days)
Show older comments
I want to verify that two transfer functions are equal.
For example:
Kc = 0.4262; Ti=1.35;
C1 = pidstd(Kc,Ti);
tf(C1)
s = tf('s');
Gc1 = Kc*(1+1/(Ti*s))
assert(tf(C1) == Gc1)
Raises:
Undefined operator '==' for input arguments of type 'tf'.
Also note:
Gc1
tf(C1)
Gc1 - tf(C1)
Gc1 =
0.5754 s + 0.4262
-----------------
1.35 s
Continuous-time transfer function.
ans =
0.4262 s + 0.3157
-----------------
s
Continuous-time transfer function.
ans =
0
Static gain.
0 Comments
Accepted Answer
Walter Roberson
on 12 Aug 2020
Edited: Walter Roberson
on 12 Aug 2020
isequal(tfdata(tf(C1) - Gc1), {[0]})
This will probably fail if there are delays in the tf.
5 Comments
Walter Roberson
on 12 Aug 2020
tf are deliberately designed to commonly be used in arrays, Number of Inputs by Number of Outputs of them. So tfdata is designed to return the numerators of each of the tf array elements in distinguishable form, with the elements commonly not being the same length as each other. Rather than build a multidimensional array of coefficients with the first or last dimension being padded out to the longest numerator, and each element padded with leading zeros to match the longest numerator, the tfdata function simply creates a cell array of the numerators, like arrayfun of tfdata with 'uniform, 0. In the case of a scalar tf, that gives you a scalar cell array. tfdata does not then special case that scalar cell to extract the contents.
More Answers (2)
Bill Tubbs
on 6 Nov 2020
Edited: Bill Tubbs
on 6 Nov 2020
4 Comments
Paul
on 7 Nov 2020
Well, based on my own experience you never know what a student will submit ;).
I'm not aware of any built-in way to display the transfer function in the form of (as+1)/(bs+1). You could probably write your own, but probably not worth it.
I suppose another alternative that doesn't rely on comparing transfer functions algebraically would be to come up with some criteria on the difference between the impulse responses for the two cases.
See Also
Categories
Find more on Classical Control Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!