Filter löschen
Filter löschen

simplifying mathematics of symbolic expression

2 Ansichten (letzte 30 Tage)
Suma
Suma am 15 Mär. 2014
Kommentiert: Suma am 19 Mär. 2014
I have a symbolic matrix
[ cos(conj(x))*cos(x), cos(conj(x))*exp(a*i)*sin(x)]
[ sin(conj(x))*exp(-conj(a)*i)*cos(x), sin(conj(x))*exp(a*i)*exp(-conj(a)*i)*sin(x)]
It looks so difficult and ugly. I am looking for simplified expression for the above something like the one below-
[ (cos(x))^2 cos(x)*exp(a*i)*sin(x)]
[sin(x)*exp(-conj(a)*i)*cos(x) (sin(x))^2 ]
since x is angle it does not have conjugate so I would like to have cos(conj(x)) as cos(x) and therefore cos(conj(x))*cos(x) as (cos(x))^2 or even better cos2x where 2 is in superscript as we normally have while writing.
Also exp(a*i)*exp(-conj(a)*i) would normally have cancelled out to give 1 but the resulted expression doesn't simplify to it
Can anybody help me here
thanks very much

Antworten (1)

Star Strider
Star Strider am 15 Mär. 2014
Bearbeitet: Star Strider am 15 Mär. 2014
You are not telling the Symbolic Toolbox everything you know about your system. See if this code does something similar to what you want:
syms x a
assume(a, 'real')
assumeAlso(x, 'real')
f = [ [ cos(conj(x))*cos(x), cos(conj(x))*exp(a*i)*sin(x)]; [ sin(conj(x))*exp(-conj(a)*i)*cos(x), sin(conj(x))*exp(a*i)*exp(-conj(a)*i)*sin(x)] ]
fs = simplify(collect(f))
Note that when it knows that x is real, it eliminates conj(x).
‘Also exp(a*i)*exp(-conj(a)*i) would normally have cancelled out to give 1 but the resulted expression doesn't simplify to it’
It does now that it knows what you know about a:
g = exp(a*i)*exp(-conj(a)*i)
Experiment with it and the various functions in the Symbolic Toolbox to get the result in the form you want.
If you want it as a function you can execute as regular MATLAB code (outside of the Symbolic Math Toolbox), see matlabFunction.
  11 Kommentare
Walter Roberson
Walter Roberson am 17 Mär. 2014
Try with x = 2 + 3*i and you will see that cos(conj(x))*cos(x) is not the same as (cos(x))^2
Suma
Suma am 19 Mär. 2014
ok thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox 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!

Translated by