How to simplify a symbolic matrix
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SOURAV KUMAR
le 15 Fév 2021
Réponse apportée : Swatantra Mahato
le 18 Fév 2021
Hello everyone,
I was trying the following code:
clc
clear all
close all
syms a k1 k2;
A=[exp(-i*k1*a) 0; 0 exp(i*k1*a)];
B=[k2+k1 k1-k2; k1-k2 k2+k1];
C=[exp(i*k2*a) 0; 0 exp(-i*k2*a)];
D=[exp(i*k2*a) 0; 0 exp(-i*k2*a)];
E=[k2+k1 k2-k1; k2-k1 k2+k1];
F=[exp(-i*k1*a) 0; 0 exp(i*k1*a)];
T=((((A*B)*C)*D)*E)*F;
T=T/(4*k1*k2);
T=simplify(T);
fprintf('T11=\n%s \n',char(T(1,1)));
fprintf('T12=\n%s \n',char(T(1,2)));
fprintf('T21= \n%s \n',char(T(2,1)));
fprintf('T22= \n%s \n',char(T(2,2)));
In this code, i am trying to evaluate T matrix;
I want to simplify the individual components of T matrix {i.e., T(1,1) , T(1,2) , T(2,1) & T(2,2) }
I searched it on internet and found "simplify" will perform the above task.
But , for the above code, the result is yet unsimplified,
i.e., i am getting T(1,1) output as
(exp(a*k1*(-i))*(exp(a*k1*(-i))*exp(a*k2*(2*i))*(k1 + k2)^2 - exp(a*k1*(-i))*exp(a*k2*(-2*i))*(k1 - k2)^2))/(4*k1*k2)
i.e., ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/519572/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/519572/image.png)
but we can see that
from the inner bracket
can be further taken out to simplify the result ;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/519577/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/519582/image.png)
hence how to simplify the results of the above code?
0 commentaires
Réponse acceptée
Swatantra Mahato
le 18 Fév 2021
Hi Sourav,
As mentioned in the documentation for "simplify" there is no universal idea to the simplest form of an expression. You may want to try out different Name-Value Pair arguments mentioned in the documentation to get the desired form suitable for your use case
As an example,
executing
T=simplify(T,'Steps',20);
instead gives
T12=
-(exp(-a*k2*2i)*(k1^2 - k2^2)*(exp(a*k2*4i) - 1))/(4*k1*k2)
while
T=simplify(T,'Steps',30);
gives the result
T12=
-(sin(2*a*k2)*(k1^2 - k2^2)*1i)/(2*k1*k2)
Hope this helps
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Number Theory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!