Finding real and imaginary part of an equation

2 次查看(过去 30 天)
syms U P
P = sqrt((((20*U^2) -15) + sqrt((400*U^4)+ (1080*U^2) + 25 -600 - 450 - (1125/U^2))) / ((36*U^2) + 30));
p = solve(P);
real_part_U = real(p);
imaginary_part_U = imag(p);
disp(real_part_U);
disp(imaginary_part_U);
plot (p,imaginary_part_U);
Warning: Imaginary parts of complex X and/or Y arguments ignored.
I have an equation of p in terms of U for which I need to find real and imaginary part of p in terms of U and plot the imag(p) wrt U. I don't get the correct graph by using above code. What am I doing wrong?

回答(2 个)

Walter Roberson
Walter Roberson 2023-12-4
You extracted the real part into a variable but you plot() the complex variable.
syms U P
P = sqrt((((20*U^2) -15) + sqrt((400*U^4)+ (1080*U^2) + 25 -600 - 450 - (1125/U^2))) / ((36*U^2) + 30));
p = solve(P);
real_part_U = real(p);
imaginary_part_U = imag(p);
disp(real_part_U);
disp(imaginary_part_U);
plot(real_part_U,imaginary_part_U);
  2 个评论
Ritu Bhalodia
Ritu Bhalodia 2023-12-4
That still doesn't give me the answer I want. Note that p is a solution of an equation I solved manually. I need to separate the p equation in terms of real and imaginary part in order to plot imaginary part wrt U.
Torsten
Torsten 2023-12-4
It's not easy to understand what you want.
You are given P, you solve
P = sqrt((((20*U^2) -15) + sqrt((400*U^4)+ (1080*U^2) + 25 -600 - 450 - (1125/U^2))) / ((36*U^2) + 30));
for U and after this, you want to plot imag(P) vs. U ? What if U is complex ?

请先登录,再进行评论。


Torsten
Torsten 2023-12-4
移动:Torsten 2023-12-4
U = 0:0.1:10;
P = sqrt((((20*U.^2)-15) + sqrt((400*U.^4)+ (1080*U.^2) + 25 -600 - 450 - (1125./U.^2)))./((36*U.^2) + 30));
Pimag = imag(P);
plot(U,Pimag)

类别

Help CenterFile Exchange 中查找有关 Formula Manipulation and Simplification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by