How to simplify a symbolic matrix

48 次查看(过去 30 天)
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.,
but we can see that from the inner bracket can be further taken out to simplify the result ;
hence how to simplify the results of the above code?

采纳的回答

Swatantra Mahato
Swatantra Mahato 2021-2-18
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 个)

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

产品


版本

R2013a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by