Use MatLab to convert between state space representations

This script requires the MatLab's symbolic toolbox

% Start by clearing everything
clear all
clc

Declare all symbolic variables

syms a1 a2 a3 a4 b0

Define state space system

A=[0 1 0 0; 0 0 1 0; 0 0 0 1; -a4 -a3 -a2 -a1];
B=[0; 0; 0; b0;];
C=[1 0 0 0];
D=0;

% Define transition matrix
R=[0.5 0.5 0 0; -0.5 0.5 0 0; 0 0 1 0; 0 0 0 1];

%Find new state space representation
Anew=inv(R)*A*R
Bnew=inv(R)*B
Cnew=C*R
Dnew=D
 
Anew =
 
[        -1/2,           1/2,  -1,   0]
[        -1/2,           1/2,   1,   0]
[           0,             0,   0,   1]
[ a3/2 - a4/2, - a3/2 - a4/2, -a2, -a1]
 
 
Bnew =
 
  0
  0
  0
 b0
 

Cnew =

    0.5000    0.5000         0         0


Dnew =

     0