else statement is showing error

1 回表示 (過去 30 日間)
trilochan
trilochan 2013 年 10 月 16 日
コメント済み: trilochan 2013 年 10 月 16 日
can any one tell me why the else statement is showing an error in my code
for Re1=3000 if x<Re1 f1=mc+cof+((Re1-x)*0.18)-(x*0.18)-(Rh1*0.05); end else f1=mc+cof-(Re1*0.18)-(Rh1*0.05); end end

採用された回答

Image Analyst
Image Analyst 2013 年 10 月 16 日
編集済み: Image Analyst 2013 年 10 月 16 日
You have an else that has no if to start it off. Your prior if was ended with the end in the line right before the else. Try getting rid of that if that's what you want to do.
for Re1=3000
if x<Re1
f1=mc+cof+((Re1-x)*0.18)-(x*0.18)-(Rh1*0.05);
else
f1=mc+cof-(Re1*0.18)-(Rh1*0.05);
end
end
Of course I hope you realize your for loop will go only once , for a value of Re1 of 3000.
  1 件のコメント
trilochan
trilochan 2013 年 10 月 16 日
thank you

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by