calculate the Γ matrix in MATLAB from Φ Matrix - State space equation
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rajesh Kanesan
el 9 de Jun. de 2022
Comentada: Sam Chak
el 11 de Jun. de 2022
Could you please advise me if there is a function to calculate the Γ matrix in MATLAB from Φ Matrix?
5 comentarios
Paul
el 9 de Jun. de 2022
So the goal is to compute phi and gamma from A and B?
Why is phi computed twice in the same way in the code above, but the code doesn't compute gamma.
Is a symbolic solution desired? Or a numerical solution for a specified value of the sampling period, T?
Respuesta aceptada
Paul
el 10 de Jun. de 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 comentarios
Paul
el 10 de Jun. de 2022
Editada: Paul
el 11 de Jun. de 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)
Más respuestas (1)
Sam Chak
el 10 de Jun. de 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 comentarios
Paul
el 11 de Jun. de 2022
At the risk of stating the obvious, need to enusre that A is invertible before using this equation in Matlab.
Also, something changed between 2022a and 2021b.
Running here on Answers with 2022a with A singular:
A = [1 1;0 0];
syms T
A\(expm(A*T-eye(2)))
But when I run this same problem on my local installation of 2021b I get
>> A = [1 1; 0 0];
>> syms T
>> A\(expm(A*T) - eye(2))
Warning: Solution is not unique because the system is rank-deficient.
> In symengine
In sym/privBinaryOp (line 1136)
In \ (line 497)
ans =
[exp(T) - 1, exp(T) - 1]
[ 0, 0]
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!