フィルターのクリア

disp

10 ビュー (過去 30 日間)
Tor Fredrik Hove
Tor Fredrik Hove 2011 年 10 月 31 日
if b>a & b>c
disp(b)
elseif c>a & c>b
disp(c)
else disp(a)
disp(a)
end
I have defined:
>> a
a =
24
>> b
b =
42
>> c
c =
64
when I run this the if/else works and i get 64
but it does not disp a afterwards. Why not?
  1 件のコメント
Jan
Jan 2011 年 10 月 31 日
You can copy the lines to a function and use the debugger to step through the code line by line. This is usually more helpful for learning than letting Walter find the problem.

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

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 31 日
The final disp(a) is within the scope of the last else. "else" does not terminate until an "end" -- you are not limited to providing only a single statement in an if or elseif or else clause.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by