Filter löschen
Filter löschen

Finding real and imaginary part of an equation

2 Ansichten (letzte 30 Tage)
Ritu Bhalodia
Ritu Bhalodia am 4 Dez. 2023
Kommentiert: Torsten am 4 Dez. 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?

Antworten (2)

Walter Roberson
Walter Roberson am 4 Dez. 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 Kommentare
Ritu Bhalodia
Ritu Bhalodia am 4 Dez. 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 am 4 Dez. 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 ?

Melden Sie sich an, um zu kommentieren.


Torsten
Torsten am 4 Dez. 2023
Verschoben: Torsten am 4 Dez. 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)

Kategorien

Mehr zu Formula Manipulation and Simplification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by