# calculate the Γ matrix in MATLAB from Φ Matrix - State space equation

3 views (last 30 days)
Rajesh Kanesan on 9 Jun 2022
Commented: Sam Chak on 11 Jun 2022
Could you please advise me if there is a function to calculate the Γ matrix in MATLAB from Φ Matrix?
Rajesh Kanesan on 9 Jun 2022
Thanks for your response . Symbolic should be sufficient with the T .

Paul on 10 Jun 2022
Let's see what we have so far:
A = [0 1; -1 -1];
b = [0;1];
I = eye(2);
syms s;
LaplaceTransitionMatrix = (s*I-A)^-1
LaplaceTransitionMatrix = phi = ilaplace(LaplaceTransitionMatrix)
phi = Note that phi is a function of t, because that's the default variable for ilaplace(). But we can replace that with T
syms t T
phi = subs(phi,t,T)
phi = Now that we have phi, do you have a formula for gamma? If so, the code you're trying to use to implement that formula.
Paul on 10 Jun 2022
Ok. Let's see how we can solve the problem a couple of ways in Matlab
A = [0 1; -1 -1];
B = [0;1];
I = eye(2);
syms s
LaplaceTransitionMatrix = (s*I-A)^-1;
phi = ilaplace(LaplaceTransitionMatrix);
syms t T
phi = subs(phi,t,T);
Compute gamma via its defining integral
syms tau
gamma1 = simplify(int(subs(phi,T,tau)*B,tau,0,T))
gamma1 = With A invertible, compute gamma via the very cool equation provide by @Sam Chak
gamma2 = simplify(A\(phi - I)*B)
gamma2 = We can also compute phi and gamma simultaneously
temp = expm([A*T B*T;zeros(1,3)]);
phi3 = simplify(rewrite(temp(1:2,1:2),'sincos'),100)
phi3 = gamma3 = simplify(expand(rewrite(temp(1:2,3),'sincos')),100,'Criterion','PreferReal')
gamma3 = I don't know why it's so difficult to get gamma3 into simpler form, but it is the same as gamma2
simplify(gamma3 - gamma2)
ans = Get the numerical representation assuming a sampling period of T = 0.1
vpa(subs(phi,T,0.1),4)
ans = vpa(subs(gamma1,T,0.1),4)
ans = Show that phi and gamma can be computed numerically.
First approach
T = 0.1;
phi = expm(A*T)
phi = 2×2
0.9952 0.0950 -0.0950 0.9002
gamma1 = integral(@(tau) (expm(A*tau)*B),0,T,'ArrayValued',true)
gamma1 = 2×1
0.0048 0.0950
gamma2 = A\(phi - eye(2))*B
gamma2 = 2×1
0.0048 0.0950
temp = expm([A*T B*T;zeros(1,3)]);
phi3 = temp(1:2,1:2)
phi3 = 2×2
0.9952 0.0950 -0.0950 0.9002
gamma3 = temp(1:2,3)
gamma3 = 2×1
0.0048 0.0950

Sam Chak on 10 Jun 2022
Thanks for showing your calculation of the Gamma or Γ, I see now... Given the matrices and , you want to go from the continuous-time to the discrete-time where , to obtain in terms of the sampling period T.
Since , and
if what I think about what you want is correct, then you may use this:
syms T
A = [0 1; -1 -1]
B = [0; 1]
Bd = simplify(Bd)
You can check with @Paul if this approach can be admitted or not.
Sam Chak on 11 Jun 2022
Thanks @Paul for highlighting it. The formula only works if the matrix is non-singular.