フィルターのクリア

Invalid syntax: Might be missing a closing

15 ビュー (過去 30 日間)
azaandria
azaandria 2021 年 2 月 5 日
コメント済み: Star Strider 2021 年 2 月 5 日
Hello, any help would be greatly appreciated!!!!
Getting the following error on line 16:
Invalid Syntax at 'R'. A '(' Might be missing a closing ')'
Here is my code below:
%This program determines the height H for given values of r, R, and total
%volume VTotal
%
clear
clc
r=30;
%Radius of cylinder in ft
R=45;
%Radius of cylinder cap in ft
V=120000^3;
%Total Volume of cylindrical silo
x=asind(r/R);
%Calculations for Theta
h=R*(1-cos(x));
%Height of Cylinder cap
Vcap=(1/3)*pih^2*(3R-h);
%Volume of Cylinder cap
Vcyl=(V-Vcap);
%Volume of Cylinder
disp('Height of Cylinder is:')
H=Vcyl/(pi(r)^2);
%End-of-file

採用された回答

Star Strider
Star Strider 2021 年 2 月 5 日
You’re missing an operator! (Actually several of them!)
In:
Vcap=(1/3)*pih^2*(3R-h);
there should be something between ‘R’ and ‘3’. I am guessing it should be:
Vcap=(1/3)*pi*h^2*(3*R-h);
instead, since MATLAB does not recognise implied multiplication.
Further down:
H=Vcyl/(pi(r)^2);
should be:
H=Vcyl/(pi*(r)^2);
although the parentheses around ‘r’ are not necessary.
  2 件のコメント
azaandria
azaandria 2021 年 2 月 5 日
Thank you so much!
Star Strider
Star Strider 2021 年 2 月 5 日
As always, my pleasure!
Also, consider this change:
%Volume of Cylinder
H=Vcyl/(pi(r)^2);
fprintf(1,'Height of Cylinder is: %10.4f\n',H)
%End-of-file
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by