Array of transfer function (nxn) when multplied with an array of constant nx1 give issue

3 views (last 30 days)
Array of transfer function (nxn) when multplied with an array of constant nx1 in the fashion
inv(s*eye(3)-A)*M
Where A is a 3x3 matrices with constants and M is 3x1 array with contants.
inv(s*eye(3)-A) gives an array of transfer functions with the same denominator. So when multiplied by M it should just be a linear combination of the elements and have the expression a/tf + b/tf + c/tf which should be (a+b+c)/tf where a,b,c could be transfer functions. However, MATLAB returns the output as (a*tf^2 + b*tf^2 + c*tf^2)/tf^3(here tf is the transfer function of the denominator). This causes issue to understand the bodeplot and the pole zeros of this trasnfer function.
  1 Comment
Walter Roberson
Walter Roberson on 8 Mar 2025
Edited: Walter Roberson on 8 Mar 2025
%example
s = tf('s');
A = magic(3);
M = [2;1;4];
G = inv(s*eye(3)-A)*M
G = From input to output... 2 s^8 - 49 s^7 - 122 s^6 + 9207 s^5 - 3.045e04 s^4 - 3.573e05 s^3 + 1.562e06 s^2 + 3.948e06 s - 1.892e07 1: ------------------------------------------------------------------------------------------------------------------- s^9 - 45 s^8 + 603 s^7 - 135 s^6 - 4.687e04 s^5 + 1.652e05 s^4 + 1.153e06 s^3 - 5.21e06 s^2 - 9.331e06 s + 4.666e07 s^8 - 6 s^7 - 659 s^6 + 9168 s^5 + 3804 s^4 - 4.297e05 s^3 + 9.009e05 s^2 + 5.115e06 s - 1.503e07 2: ------------------------------------------------------------------------------------------------------------------- s^9 - 45 s^8 + 603 s^7 - 135 s^6 - 4.687e04 s^5 + 1.652e05 s^4 + 1.153e06 s^3 - 5.21e06 s^2 - 9.331e06 s + 4.666e07 4 s^8 - 155 s^7 + 1852 s^6 - 3255 s^5 - 7.466e04 s^4 + 4.241e05 s^3 + 1.621e05 s^2 - 6.16e06 s + 1.218e07 3: ------------------------------------------------------------------------------------------------------------------- s^9 - 45 s^8 + 603 s^7 - 135 s^6 - 4.687e04 s^5 + 1.652e05 s^4 + 1.153e06 s^3 - 5.21e06 s^2 - 9.331e06 s + 4.666e07 Continuous-time transfer function.
N = cellfun(@poly2sym, G.Num)
N = 
D = cellfun(@poly2sym, G.Den)
D = 
factor(D(1))
ans = 
The denominator did not factor into anything^3, so the hypthosis that it is /tf^3 would seem to be false.

Sign in to comment.

Accepted Answer

Paul
Paul on 8 Mar 2025
Edited: Paul on 8 Mar 2025
Example matrices
rng(100);
A = rand(3); M = rand(3,1);
s = tf('s');
T = inv(s*eye(3)-A)
T = From input 1 to output... s^2 - 0.1414 s - 0.09975 1: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.2784 s + 0.3125 2: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.4245 s + 0.03184 3: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 From input 2 to output... 0.8448 s - 0.03394 1: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 s^2 - 0.6801 s - 0.2105 2: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.1216 s + 0.2926 3: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 From input 3 to output... 0.6707 s + 0.6945 1: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.8259 s - 0.2621 2: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 s^2 - 0.5481 s - 0.2326 3: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 Continuous-time transfer function.
H = T*M
H = From input to output... 0.5751 s^8 + 0.02427 s^7 - 1.409 s^6 - 0.418 s^5 + 0.5442 s^4 + 0.6569 s^3 + 0.2698 s^2 + 0.05786 s + 0.003082 1: ---------------------------------------------------------------------------------------------------------------- s^9 - 2.054 s^8 - 0.2214 s^7 + 1.216 s^6 + 1.07 s^5 - 0.1777 s^4 - 0.5152 s^3 - 0.3141 s^2 - 0.08702 s - 0.01235 0.8913 s^8 - 1.494 s^7 - 0.2379 s^6 + 0.505 s^5 + 0.5066 s^4 + 0.03899 s^3 - 0.05927 s^2 - 0.03034 s - 0.003349 2: ---------------------------------------------------------------------------------------------------------------- s^9 - 2.054 s^8 - 0.2214 s^7 + 1.216 s^6 + 1.07 s^5 - 0.1777 s^4 - 0.5152 s^3 - 0.3141 s^2 - 0.08702 s - 0.01235 0.2092 s^8 - 0.04871 s^7 - 0.2243 s^6 - 0.4034 s^5 + 0.05266 s^4 + 0.2627 s^3 + 0.2117 s^2 + 0.07053 s + 0.01231 3: ---------------------------------------------------------------------------------------------------------------- s^9 - 2.054 s^8 - 0.2214 s^7 + 1.216 s^6 + 1.07 s^5 - 0.1777 s^4 - 0.5152 s^3 - 0.3141 s^2 - 0.08702 s - 0.01235 Continuous-time transfer function.
Your are correct that each element of H should have a third order denominator. But the Control Systems Toolbox doesn't "know" that every transfer function added together in H*M has the same denominator, so it does what it does and comes up with the general expression with a ninth order denominator (as would be obtained by adding fractions by first doing cross multiplication to form a common denominator).
You can get the expected result by applying minreal, albeit with a very high tolerance.
minreal(H,1e-4)
ans = From input to output... 0.5751 s^2 + 0.812 s + 0.05767 1: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.8913 s^2 - 0.2733 s - 0.06267 2: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.2092 s^2 + 0.2378 s + 0.2304 3: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 Continuous-time transfer function.
However, the correct approach is to not use inv and transfer function math in the first place. Rather, just build a ss model from the outset and go from there
H = ss(A,M,eye(3),0);
Now you can find poles, zeros, bodeplots, etc, w/o converting to a transfer function at all. There is no reason to do so. If you just want to see what the tf is, then
tf(H)
ans = From input to output... 0.5751 s^2 + 0.812 s + 0.05767 1: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.8913 s^2 - 0.2733 s - 0.06267 2: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 0.2092 s^2 + 0.2378 s + 0.2304 3: ------------------------------------ s^3 - 0.6848 s^2 - 0.5428 s - 0.2312 Continuous-time transfer function.
but all numeric computations should be done on the ss form of H.
I assumed that the "problem" is with usage of the Control System Toolbox. However, the tags on the question suggest that the Symbolic Math Toolbox might be in use. But, at least for this example, the SMT does not return the reported result
syms s
H = inv(s*eye(3)-A)*M;
vpa(H,5)
ans = 
The common denominator in all terms is third order, as expected. The result can be simplified
vpa(simplify(H),5)
ans = 
To get leading coefficient of the denomintaor to unity (to within a sign)
[num,den]=numden(H)
num = 
den = 
for ii = 1:3
c = coeffs(den(ii),'all');
num(ii) = num(ii)/c(1);
den(ii) = den(ii)/c(1);
end
H = num./den;
vpa(H,5) % same result as above
ans = 

More Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!