Azzera filtri
Azzera filtri

Finding real and imaginary part of an equation

2 visualizzazioni (ultimi 30 giorni)
Ritu Bhalodia
Ritu Bhalodia il 4 Dic 2023
Commentato: Torsten il 4 Dic 2023
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?

Risposte (2)

Walter Roberson
Walter Roberson il 4 Dic 2023
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 Commenti
Ritu Bhalodia
Ritu Bhalodia il 4 Dic 2023
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 il 4 Dic 2023
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 ?

Accedi per commentare.


Torsten
Torsten il 4 Dic 2023
Spostato: Torsten il 4 Dic 2023
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)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by