Im trying to code the following equation (Attached) in MATLAB, could someone please tell me if i coded it right. Thanks

1 回表示 (過去 30 日間)
eqn=Ma.*sqrt(gam.*R.*Ta).*((1+f).*sqrt(T04./Ta).*(1+((gam-1)./2).*Ma.^2).^(-0.5))-1

回答 (1 件)

OCDER
OCDER 2018 年 10 月 15 日
eqn= Ma.*sqrt(gam.*R.*Ta).*((1+f).*sqrt(T04./Ta).*(1+((gam-1)./2).*Ma.^2).^(-0.5))-1
^ WRONG PLACE
Note: You do not need the dot-multiplier (.*) when multiply a scalar value to a matrix. Use the elementy-wise, dot-multiplier when multiplying two matrices together, element-by-element.
EX:
A = 1;
B = 2;
C = A * B; %OK
A = 1;
B = [1 2 3];
C = A * B; %OK
A = [1 2 3];
B = [1 2 3];
C = A .* B; %OK to use .* multiplier if you want C = [1 4 9].
  4 件のコメント
OCDER
OCDER 2018 年 10 月 15 日
Believe in yourself Faraz! YOU need to be able to decide what's right or wrong yourself. The different levels of confidence...
"should it be after -1?" (lacking confidence because of fear of failing)
"it should be after -1 because the brackets surround -1" (justified confidence, failed and learned many times)
"it should be after -1 because I'm always right" (over confidence, failed a lot but never learned)
"it should be after -1 because others said so. " (false confidence, majority can be incorrect too)
But, are you even sure the bracket should be after -1? Just testing :)

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by