0

Motivation: I have to iteratively determine transfer functions of a system depending on its parameters. From the block diagram, I know the matrix equations and now have to combine and solve them to obtain the transfer function. The system is not given in any common form, so I can't just apply standard functions as for example ss2f.

Problem: To test my equation solving script, I started with a problem I know the solution to: System desciption

The transfer function G of this system can be directly calculated as follows with s as the Laplace variable: Transfer function direct calculation

Now I want to obtain the same solution with the following script that I wrote. Don't worry about the weird numbers of A and B, the system was determined via model linearization. It definitely has a valid transfer function though, as above formula has a valid result. However, the last line of the script gives me:

ans = 

  struct with fields:

g1: [0×1 sym]
g3: [0×1 sym]
g2: [0×1 sym]
g4: [0×1 sym]

Below is my code. Hope you can help me with that. Thanks in advance!

System matrix: 4x4
A = [-0.868119260443192,38.6220008060345,-3.41464245222828,0;-0.977364157120952,-0.710033524230589,0.0269276394855778,0.576935314629657;4.02838694184468,-15.0624095995407,-31.0586647741313,0;0.0225429037937697,0,1,-3.32771392487994e-30];
% Input Matrix 4x2
B = [-7.66837152645279,-21.1508491865230;-0.0466721502330690,0.198650074689473;-112.758863363750,-2.59747270711686;0,0];
% Output matrix 2x4
C = [0 0 1 0; 0 1 0 0];

% Transfer function
syms g1 g2 g3 g4;
G = [g1 g2; g3 g4];

% System vector and derivative
syms x1 x2 x3 x4 xp1 xp2 xp3 xp4;
x = [x1;x2;x3;x4];
xp = [xp1;xp2;xp3;xp4];

% Input u and output y
syms u1 u2;
u = [u1;u2];
syms y1 y2;
y = [y1;y2];

% System equations
eqn1 = xp == A * x + B * u;
eqn2 = y == C * x;

% Transfer function equation
eqn3 = y == G * u;

% xp is derivative of x
syms s;
eqn4 = s .* x == xp;

solve(eqn1, eqn2, eqn3, eqn4, G)
Geralt von Riva
  • 324
  • 3
  • 16
  • you need `solve(eqn,vars)` with `eqn` being a vector of `n` symbolic expressions and `vars` a vector of `n` unknown symbols. – John Alexiou Jul 18 '21 at 23:05
  • I think the syntax within the solve line is correct. If I combine eqn 1 through 4 in a vector, Matlab throws an error. G is already a vector/matrix. – Geralt von Riva Jul 19 '21 at 07:01

0 Answers0