1D Element Wise Arithmetic Operators: Mismatched delimiters?

3 ビュー (過去 30 日間)
Kevin Carty
Kevin Carty 2020 年 2 月 21 日
コメント済み: Guillaume 2020 年 2 月 21 日
function surfaceArea = surfaceBalloon(Volume,M)
radius = sqrt((3*Volume)/((pi)(2+M))); % We are given a volume and we must solve for the radius in order to plug into formula below
surfaceArea = pi*(radius)^2(2+sqrt(1+(M)^2);
end
Error in solution: Line: 2 Column: 36
Invalid expression. When calling a function or indexing a
What am I doing wrong? I thought you only use dot operators when multiplying, dividing, or raising to a power with another array. These are just being multiplied/raised by scalar values.
variable, use parentheses. Otherwise, check for mismatched delimiters.

回答 (1 件)

fred  ssemwogerere
fred ssemwogerere 2020 年 2 月 21 日
Hello you are missing a multiplication sign, in the denominator (line 2). Multiplication with parentheses is not supported without the multiplication operator.
radius = sqrt((3*Volume)/(pi*(2+M)));
  1 件のコメント
Guillaume
Guillaume 2020 年 2 月 21 日
I'd recommend cutting down on the brackets:
radius = sqrt(3*Volume / (pi*(2+M)));

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

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by