フィルターのクリア

what is the wrong with my code?

2 ビュー (過去 30 日間)
Hesham Islam
Hesham Islam 2023 年 5 月 13 日
回答済み: Shaik 2023 年 5 月 13 日
z=6;
if z==6
prompt = "what type of threaded pipe fitting (Globe (1)/Angle (2)/GateWide (3)/Gatehalf (4)/Return (5)/Tee (6)/Straight-Through (7)/Side-outlet (8)/90 (9)/45 (10)): ";
y=input(prompt,"s");
if y=='1'
k=10;
else
if y=='2'
k=5;
else
if y=='3'
k=0.2;
else
if y=='4'
k=5.6;
else
if y=='5'
k=2.2;
else
if y=='6'
k=0.4;
else
if y=='7'
k=1.8;
else
if y=='8'
k=0.9;
else
if y=='9'
k=0.4;
else
y="Error";
end
end
end
end
end
end
end
end
end
end
  1 件のコメント
Torsten
Torsten 2023 年 5 月 13 日
Please include the complete error message.

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

採用された回答

Shaik
Shaik 2023 年 5 月 13 日
Hi,
check this
z = 6;
if z == 6
% Assign the desired value of y based on your requirements
y = '6'; % Example: Assigning '6' for Tee fitting
switch y
case '1'
k = 10;
case '2'
k = 5;
case '3'
k = 0.2;
case '4'
k = 5.6;
case '5'
k = 2.2;
case '6'
k = 0.4;
case '7'
k = 1.8;
case '8'
k = 0.9;
case '9'
k = 0.4;
case '10'
k = 0.45;
otherwise
disp("Invalid option.");
% Handle the error condition based on your program's logic.
end
end

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by