亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

MATLAB 嵌套的if語句

Matlab 條件語句

在 MATLAB 中嵌套 if-else 語句總是合法的,這意味著您可以在另一個 if 或 elseif 語句中使用 if 或 elseif 語句。

語法

嵌套if語句的語法如下-

if <expression 1>
   %當(dāng)布爾表達(dá)式1為true時執(zhí)行 
   if <expression 2>
      %當(dāng)布爾表達(dá)式2為true時執(zhí)行
   end
end

您可以嵌套elseif ... else,就像嵌套if語句一樣。

在線示例

創(chuàng)建一個腳本文件并在其中鍵入以下代碼-

a = 100;
b = 200;
   %檢查布爾條件
   if( a == 100 )
   
      %如果condition為真,則檢查以下內(nèi)容
      if( b == 200 )
       
         %如果condition為真,則打印以下內(nèi)容
         fprintf('Value of a is 100 and b is 200\n' );
      end
       
   end
   fprintf('Exact value of a is : %d\n', a );
   fprintf('Exact value of b is : %d\n', b );
運(yùn)行文件時,它顯示-
Value of a is 100 and b is 200
Exact value of a is : 100
Exact value of b is : 200

Matlab 條件語句