Solve Equation and Plot it

18 ビュー (過去 30 日間)
Daniela Würmseer
Daniela Würmseer 2022 年 6 月 17 日
コメント済み: Star Strider 2022 年 6 月 17 日
Hello, i have the follwing equation:
0 = 0.5*alpha*(w(1)*f_1-w(2)*f_2)^2+p(1)*f_1+p(2)*f_2+skalar- AF_z
which i want to write like f_2 = ... and plot after f_2 for f_1 = linspaces(0,20).
At this moment we already know that alpha = 0.4207, skalar = 4.5375, AF_z = 5,9796, w = [0.77,0.23], p = [-0.9851,0.5243]. So the only values we do not know is f_1 and f_2
So i started like this:
syms f_1 f_2
g = 0.5*alpha*(w(1)*f_1-w(2)*f_2)^2+p(1)*f_1+p(2)*f_2+skalar- AF_z;
x = solve(g,f_2);
As there is a root (+/- sqrt), when reshaping the equation to f2 =..., the structure of x is 2x1 sym.
And now i want to plot for all f_1 betweem 0 and 20 the f_2 values.
I know that i need to use fplot.
The solution should look like the pic.
Thank you already for the help

採用された回答

Star Strider
Star Strider 2022 年 6 月 17 日
The result ie not exactly the same as the plot in the original question, however it is close —
alpha = 0.4207;
skalar = 4.5375;
AF_z = 5.9796;
w = [0.77,0.23];
p = [-0.9851,0.5243];
syms f_1 f_2
g = 0.5*alpha*(w(1)*f_1-w(2)*f_2)^2+p(1)*f_1+p(2)*f_2+skalar- AF_z;
x = solve(g,f_2)
x = 
figure
fplot(x, [0 10])
grid
xlim([0 20])
The dashed vertical line denotes a singularity at .
.
  2 件のコメント
Daniela Würmseer
Daniela Würmseer 2022 年 6 月 17 日
Thank you
Star Strider
Star Strider 2022 年 6 月 17 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2022 年 6 月 17 日
編集済み: John D'Errico 2022 年 6 月 17 日
Easy peasy. Essentially one line of code once you define the various constants.
syms f_1 f_2
alpha = 0.4207;
skalar = 4.5375;
AF_z = 5.9796; % You wrote 5,9796 but note that numbers in matlab are written with decimal points, not commas.
w = [0.77,0.23];
p = [-0.9851,0.5243];
fimplicit(0 == 0.5*alpha*(w(1)*f_1-w(2)*f_2)^2+p(1)*f_1+p(2)*f_2+skalar- AF_z,[-5 10 -10 20])
The exact shape will of course depend on the exact constants used. It appears the constants were subtly different to create the figure you posted.
  1 件のコメント
Daniela Würmseer
Daniela Würmseer 2022 年 6 月 17 日
Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by