How to obtain state-space matrices (A,B,C and D) from a defined set of differential equations in Octave

Dear colleagues,

I have programmed a script in Octave consisting in a set of differential equations that models a dynamic system. First, I typed them using symbolic variables and then I assigned numerical values to the constants of my system. Then, I defined vector ‘X’ as the vector containing the names of state-space variables that appear in my differential equations, vector ‘dX’ as the vector containing the names of the derivatives of the ‘X’ variables and ‘U’ as the vector containing the names of state-space inputs.

Do you know a command or a straightforward way to automatically extract the state-space A,B,C,D matrices from that set of differential equations (having defined ‘X’, ‘U’ and ‘dX’ vectors )? I know it can be done manually, but it consumes time and maybe there is a simple way using commands.

Many thanks and kind regards

There is this demo which might help you.

  • Demo of ODE with a step input and initial conditions.

Thank you. I just want to obtain A,B,C and D matrices from that set. So far I don´t need to test the step response of the system. I have searched for the demo but have not found it :sleepy:.

| Tradugen
December 28 |

  • | - |

dastew:

Demo of ODE with a step input and initial conditions

Thank you. I just want to obtain A,B,C and D matrices from that set. So far I don´t need to test the step response of the system. I have searched for the demo but have not found it :sleepy:.

https://wiki.octave.org/Symbolic_package

Did those demos help you?

I am afraid I am not searching for the evaluation of a set of differential equations on an specific point, as the demo shows.

I am searching for a straightforward way of computing the state-space representation ( i.e.: A,B,C and D matrices from: diffx=Ax+Bu, y=Cx+Du), given the set of differential equations that lead to it, other than manual re-organization.

But anyway, thanks