フィルターのクリア

Finding real and imaginary part of an equation

2 ビュー (過去 30 日間)
Ritu Bhalodia
Ritu Bhalodia 2023 年 12 月 4 日
コメント済み: Torsten 2023 年 12 月 4 日
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 Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by