Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.3 - 日本語

Change language to:
English - Français - Português

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Scilab > Scilab keywords > if then else

if then else

条件付き実行

呼び出し手順

if expr1 then statements
elseif expri then statements
....
else statements
end

説明

if 命令は論理式を評価し,その値が真の時に 一連の命令を実行します.

expri は数値または論理値を値とする式です.   expri が行列の場合, 全ての行列のエントリが真またはゼロでない場合にのみ その条件は真となります.

オプションの elseif および else により, 別の命令のグループを実行することができます. ifに対応する end キーワードにより,最後の命令のグループが 終了します. 上記の行の構造には意味がなく,唯一の拘束条件は, 各thenキーワードを対応する if または elseifキーワードと 同じ行に置く必要があることのみです.

キーワード then はキャリッジ・リターンまたはカンマで 置き換えることができます.

警告: 条件文(if while for または select/case)の内部に記述可能な文字数は 16kに制限されています.

i=2
for j = 1:3, 
  if i == j then
    a(i,j) = 2; 
  elseif abs(i-j) == 1 then 
    a(i,j) = -1; 
  else a(i,j) = 0;
  end,
end

参照

  • try — try-catch 制御命令のtryブロックを開始
  • while — while キーワード
  • select — select キーワード
  • boolean — Scilab オブジェクト, 論理値(boolean)変数および演算子 & | ~
  • end — end キーワード
  • then — if-then-elseのキーワード
  • else — if-then-elseのキーワード
<< hat Scilab keywords left >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Oct 05 12:12:30 CEST 2011