trying to write complex equation with parentheses

7 ビュー (過去 30 日間)
ali
ali 2024 年 2 月 27 日
回答済み: Sam Chak 2024 年 2 月 27 日
iam trying to write the following formula for the area ratio at Ma =1 but i think that iam missing a parentheses
note: im only trying to write the right side of the equation
code:
((k+1)/2)^(-(k+1)/(2*(k-1)))*(1+((k-1)/2)*(Ma)^2)^((k+1)/2*(k-1))/Ma
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 2 月 27 日
syms gamma M
k = gamma;
Ma = M;
f = ((k+1)/2)^(-(k+1)/(2*(k-1)))*(1+((k-1)/2)*(Ma)^2)^((k+1)/2*(k-1))/Ma
f = 
... I think that's the same.
Dyuman Joshi
Dyuman Joshi 2024 年 2 月 27 日
@Walter, the (gamma -1) in the power of numerator should be in denominator.

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

回答 (2 件)

Dyuman Joshi
Dyuman Joshi 2024 年 2 月 27 日
You were missing a pair of parenthesis -
syms gamma M
k = gamma;
Ma = M;
% v v
f = ((k+1)/2)^(-(k+1)/(2*(k-1)))*(1+((k-1)/2)*(Ma)^2)^((k+1)/(2*(k-1)))/Ma
f = 
  1 件のコメント
VBBV
VBBV 2024 年 2 月 27 日
編集済み: VBBV 2024 年 2 月 27 日
Yes, @Dyuman Joshi it seems the denominator should have a pair of parenthesis. Good catch

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


Sam Chak
Sam Chak 2024 年 2 月 27 日
Hi @ali
When inputting a lengthy equation with multiple parentheses into the programming code, I usually adopt a "divide-and-conquer" approach. This helps reduce the chances of human error and enables me to cross-verify it effortlessly with the original equation.
Consider the function
,
where the numerator N and the denominator D are given by
,
.
syms gamma M
%% numerator elements
na = 1 + (gamma - 1)/2*M^2;
nb = M;
nc = gamma + 1;
nd = 2*(gamma - 1);
%% denominator elements
da = gamma + 1;
db = 2;
dc = nc;
dd = nd;
%% the function
N = (na^(nc/nd))/nb; % numerator
D = (da/db)^(dc/dd); % denominator
f = N/D
f = 

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by