Can I separate a symbolic expression into real and imaginary components?

4 次查看(过去 30 天)
I am trying to solve a system of equations for a Vibrations problem. The matrices have one symbolic variable (w), real and imaginary components. I solve the system equation using basic matrix math, and it gives my output is in the following form:
(w*(- 340681500621583831516475 + 245114682516134139416800*i) - 2^(1/2)*w*161744841465528059953152*i + 10845775541925882888192*2^(1/2)*w^2 + 2^(1/2)*w^3*3616953450731929600*i + w^2*(- 76906298945748700000 - 11075142634881799717775*i) + 3948349625585861875*w^3 + 3922540001147731586120800 + 2633460286177396815135200*i)/(2560*(w^4*(1099511627776000*i) + 3407162234105757696*w^3 + w^2*(-71889311507307749723*i) - 584836757809722693890*w + 4461121651825735176160*i))
which is a total mess. Is there a way that I can get MATLAB to put that output in the following form?:
= [(equation in terms of w) + (equation in terms of w)*i]
Any help would be appreciated. Thanks!

回答(1 个)

Ishu
Ishu 2024-2-6
Hi Anthony,
In order to separate real and imaginary parts from an equation you can make use of "real" and imag" functions of MATLAB. You can refer to the below example.
syms w
y = 3 + 4i + w*5.5i;
y_imag = imag(y)
y_imag = 
y_real = real(y)
y_real = 
You can also use "simplify" function to further simplify your equations and to have a more clear visualization.
Below are the documentaion links you can refer to:
Hope it helps!

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by