MATLAB決策製定
決策結構要求程序員指定一個或多個條件進行評估或測試程序,沿一條或多條語句執行,如果條件被確定為真,以及可選,其他要執行的語句,如果條件確定是假的 (false)。
以下是一個典型的決策結構,發現在大多數編程語言的一般形式:
MATLAB 提供以下類型的決策報表。點擊以下鏈接,以檢查他們的細節:
語句 | 描述 |
---|---|
if ... end statement | An if ... end statement consists of a boolean expression followed by one or more statements. |
if...else...end statement | An if statement can be followed by an optional else statement, which executes when the boolean expression is false. |
If... elseif...elseif...else...end statements | An if statement can be followed by an (or more) optional elseif...and an else statement, which is very useful to test various condition. |
nested if statements | You can use one if or elseif statement inside another if or elseif statement(s). |
switch statement | A switch statement allows a variable to be tested for equality against a list of values. |
nested switch statements | You can use one swicth statement inside another switch statement(s). |