# State space models are same?

21 views (last 30 days)
Mark S on 22 Nov 2020
Answered: Paul on 23 Nov 2020
Hi, if I have two state space models, how can i calculate if these two state space models represent the same plant?

Star Strider on 22 Nov 2020
See if using the minreal function on both makes them equivalent.
I am not certain how to compare them beyond that.

Paul on 23 Nov 2020
This is actually not a trivial question. Two state space models sys1 = ss(A1,B1,C1,D1) and sys2 = ss(A2,B2,C2,D2) will have the same transfer function if there is a transformation matrix T s.t.
A2 = T*A1*inv(T)
B2 = T*B1;
C2 = C1*inv(T)
D2 = D1
So given two state space models, you need to show that D2 = D1 (obviously triivial to check) and determine if there exists an (invertible) T that would satisfy the other three equations.
One such approach would be to use the first method in this link to find a candidate T and then use
sys3 = ss2ss(sys1,T)
and check if the resulting state space matrices of sys3 are equal (to within a tolerance) to those in sys2 (caveat: sys1 and sys2 defined here are the opposite of how they are defined in that link).
If you're willing to stipulate that the plant is minimal, or at least willing to accept equality to within a "pole/zero" cancellation, then you can try using minreal on the difference
check = minreal(sys1-sys2,tol)
with the confirming result being that check is a zero m x n static gain matrix where m and n are the number of outputs and inputs of the plant respectively. You might have to play around with tol to see what works for your specific application.
For SISO cases you may also be interested in a similar question discussed here.