finding variable of a given equation

5 ビュー (過去 30 日間)
Irfan
Irfan 2024 年 10 月 19 日
コメント済み: Sam Chak 2024 年 10 月 20 日
I want to get the value of b given the equation, where AonAstar = 16 and gamma = 1.22
AonAstar = ((b)^(1/gamma)*(1-(b)^((gamma-1)/gamma))^(1/2))/(((gamma-1)/2)^(1/2)*(2/(gamma+1))^((gamma+1)/(2*(gamma-1))));

採用された回答

Walter Roberson
Walter Roberson 2024 年 10 月 19 日
編集済み: Walter Roberson 2024 年 10 月 19 日
Q = @(v) sym(v);
AonAstar = Q(16);
gamma = Q(1.22);
syms b
eqn = AonAstar == ((b)^(1/gamma)*(1-(b)^((gamma-1)/gamma))^(1/2))/(((gamma-1)/2)^(1/2)*(2/(gamma+1))^((gamma+1)/(2*(gamma-1))));
fplot(lhs(eqn) - rhs(eqn), [-2 2])
b_solution = vpasolve(eqn, b)
disp(char(b_solution))
0.88020141415289762313250086000262 + 6.1375868700814434734289784153891i
We can see from the graph that there are no solutions over the reals.
  1 件のコメント
Irfan
Irfan 2024 年 10 月 19 日
Thank you

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

その他の回答 (1 件)

John D'Errico
John D'Errico 2024 年 10 月 19 日
gamma is a really bad choice of variable names, since gamma is itself a very useful function in MATLAB. Try to avoid doing these things, because one day soon you will need to use gamma yourself as a function. I've used g instead, to replace gamma.
AonAstar = 16;
g = 1.22;
syms b
I'll subtract the right hand side from AonAstar, to create a problem where we will look for a zero.
eqn = AonAstar - (b^(1/g)*sqrt(1-b^((g-1)/g)))/((sqrt(g-1)/2)*(2/(g+1))^((g+1)/(2*(g-1))))
fplot(eqn,[0,1])
For a solution to exist, this curve must cross zero, and must do so in the interval [0,1], since it is only real valued in that interval.
As you can see, it never even comes close to zero, being always positive.
  5 件のコメント
John D'Errico
John D'Errico 2024 年 10 月 20 日
It is a habit we need to train our minds to avoid if we are to use MATLAB successfully. And yes, it is far too easy to name variables alpha, beta, gamma, and yes, I fail at it at times myself. My tendency is to use contractions, like alph, bet, gam, or I might deliberately mispell the greek letter, perhaps as gammuh. Or I'll capitalize the name, using Gamma. At least all of these variations in names remind me of the relation of my code to my thinking.
Sam Chak
Sam Chak 2024 年 10 月 20 日
These are good suggestions and practice. 👍

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

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by