Matrix symbolic calculation doesn't simplify expressions

2 visualizaciones (últimos 30 días)
Ohad Shapira
Ohad Shapira el 26 de Dic. de 2020
Comentada: Ohad Shapira el 26 de Dic. de 2020
When using syms in matrix, after matrix multipication I get expressions like that:
>> A5(3,3)
ans =
- (2^(1/2)*((2^(1/2)*w*1i)/2 - 2^(1/2)/8))/2 + (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2
(w is symbolic var)
While this entire cell is equal to 1/8
Is there any configuration I can change to make it more readable?
  2 comentarios
Ohad Shapira
Ohad Shapira el 26 de Dic. de 2020
Editada: Ohad Shapira el 26 de Dic. de 2020
Yes I did, the problem is that some times I get 1/sqrt(2) and vpa gives me a long decimal number.
(The results from this code will be used for manual calculations in furter steps)

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 26 de Dic. de 2020
try simplify - here is an example with your expression:
syms w
E = eye(3) * - (2^(1/2)*((2^(1/2)*w*1i)/2 - 2^(1/2)/8))/2 + (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2
Simple_E = simplify(E)
gives:
E =
[ - (2^(1/2)*((2^(1/2)*w*1i)/2 - 2^(1/2)/8))/2 + (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2]
[ (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, - (2^(1/2)*((2^(1/2)*w*1i)/2 - 2^(1/2)/8))/2 + (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2]
[ (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2, - (2^(1/2)*((2^(1/2)*w*1i)/2 - 2^(1/2)/8))/2 + (2^(1/2)*((2^(1/2)*w*1i)/2 + 2^(1/2)/8))/2]
Simple_E =
[ 1/4, (w*1i)/2 + 1/8, (w*1i)/2 + 1/8]
[ (w*1i)/2 + 1/8, 1/4, (w*1i)/2 + 1/8]
[ (w*1i)/2 + 1/8, (w*1i)/2 + 1/8, 1/4]

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by