How to simplify a symbolic matrix
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SOURAV KUMAR
am 15 Feb. 2021
Beantwortet: Swatantra Mahato
am 18 Feb. 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.,
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?
0 Kommentare
Akzeptierte Antwort
Swatantra Mahato
am 18 Feb. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!