calculate the Γ matrix in MATLAB from Φ Matrix - State space equation
3 views (last 30 days)
Show older comments
Could you please advise me if there is a function to calculate the Γ matrix in MATLAB from Φ Matrix?
Accepted Answer
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
phi = ilaplace(LaplaceTransitionMatrix)
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)
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.
4 Comments
Paul
on 10 Jun 2022
Edited: Paul
on 11 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))
With A invertible, compute gamma via the very cool equation provide by @Sam Chak
gamma2 = simplify(A\(phi - I)*B)
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)
gamma3 = simplify(expand(rewrite(temp(1:2,3),'sincos')),100,'Criterion','PreferReal')
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)
Get the numerical representation assuming a sampling period of T = 0.1
vpa(subs(phi,T,0.1),4)
vpa(subs(gamma1,T,0.1),4)
Show that phi and gamma can be computed numerically.
First approach
T = 0.1;
phi = expm(A*T)
gamma1 = integral(@(tau) (expm(A*tau)*B),0,T,'ArrayValued',true)
gamma2 = A\(phi - eye(2))*B
temp = expm([A*T B*T;zeros(1,3)]);
phi3 = temp(1:2,1:2)
gamma3 = temp(1:2,3)
More Answers (1)
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]
Ad = expm(A*T)
Bd = A\(Ad - eye(size(A)))*B
Ad = simplify(Ad)
Bd = simplify(Bd)
6 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!