# How would I get an inverse and transfer function of a matrix with variable s?

7 views (last 30 days)
Saad Saeed on 10 Nov 2021
Commented: Saad Saeed on 10 Nov 2021
So I'm trying to write a code that gets the inverse of a 4x4 matrix and then the transfer function for each of the 4 state inputs, the issue is these matrices include the s variable and with higher powers/coefficients. How would I go about implementing the variables into the matrix and subsequently get the transfer function?
I don't even need the code to get the transfer function as that can easily be obtained by hand if the inverse function worked with the variable, so that is the more pressing issue.
Example of what I'm trying to do and what I get:
A = [('s' + 0.06728) -0.02323 0 9.81;0.396 ('s' +1.729) -50 0;-0.0078 0.2431 ('s'+3.192) 0;0 0 -1 's'];
A_Inverse = inv(A)
Error code:
Check for missing argument or incorrect argument data type in call to function 'inv'.
Error in Matrices_Eigen (line 12)
A_Inverse = inv(A)

Paul on 10 Nov 2021
A is of class char. What I think you want is a transfer function matrix from the Control Systems Toolbox
A = [('s' + 0.06728) -0.02323 0 9.81;0.396 ('s' +1.729) -50 0;-0.0078 0.2431 ('s'+3.192) 0;0 0 -1 's'];
whos A
Name Size Bytes Class Attributes A 4x4 32 char
s = tf('s')
s = s Continuous-time transfer function.
A = [(s + 0.06728) -0.02323 0 9.81;0.396 (s +1.729) -50 0;-0.0078 0.2431 (s+3.192) 0;0 0 -1 s];
whos A
Name Size Bytes Class Attributes A 4x4 4857 tf
A
A = From input 1 to output... 1: s + 0.06728 2: 0.396 3: -0.0078 4: 0 From input 2 to output... 1: -0.02323 2: s + 1.729 3: 0.2431 4: 0 From input 3 to output... 1: 0 2: -50 3: s + 3.192 4: -1 From input 4 to output... 1: 9.81 2: 0 3: 0 4: s Continuous-time transfer function.
Ai = inv(A)
Ai = From input 1 to output... s^3 + 4.921 s^2 + 17.67 s + 1.645e-16 1: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 -0.396 s^2 - 0.874 s + 4.015e-17 2: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 0.0078 s^2 + 0.1098 s - 1.935e-18 3: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 0.0078 s + 0.1098 4: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 From input 2 to output... 0.02323 s^2 + 0.07415 s + 2.385 1: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 s^3 + 3.259 s^2 + 0.2148 s + 0.07652 2: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 -0.2431 s^2 - 0.01617 s - 1.334e-19 3: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 -0.2431 s - 0.01617 4: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 From input 3 to output... -8.649 s - 16.96 1: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 50 s^2 + 3.364 s + 3.885 2: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 s^3 + 1.796 s^2 + 0.1255 s + 3.366e-17 3: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 s^2 + 1.796 s + 0.1255 4: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 From input 4 to output... -9.81 s^2 - 48.28 s - 173.4 1: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 3.885 s + 8.574 2: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 -0.07652 s - 1.077 3: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 s^3 + 4.988 s^2 + 18.01 s + 1.209 4: --------------------------------------------- s^4 + 4.988 s^3 + 18.01 s^2 + 1.286 s + 1.077 Continuous-time transfer function.
Saad Saeed on 10 Nov 2021
Thank you so much!