HOME > テクニカルサポート > 製品 一覧 > SigmaPlot > ユーザーガイド > トランスフォーム関数一覧
ヒューリンクステクニカルサポート
皆様からのご質問のうち、よくある質問を掲載しました。
更新日: 14/05/08

if

関数 if は、指定した条件に応じて二者択一したり、指定した条件に応じて一連の計算を実行します。

 

構文

if(condition, true value, false value)

引数 true value および false value にはスカラーまたは範囲を指定します。引数 condition の条件が TRUE (真) であれば、真の場合の値を返し、FALSE (偽)であれば偽の場合の値を返します。

引数 false value を省略し、条件が偽の場合は、欠損値を返します。引数 condition がスカラーの場合は、真の場合の値、または、偽の場合の値をそのまま返します。

引数 condition の内容が範囲である場合、その結果は別の範囲を返します。条件範囲の真の要素に対しては真の場合の値を返します。条件範囲の偽の要素に対しては偽の場合の値を返します。

引数 false value を省略し、条件が偽の場合は、true value の範囲にある偽の要素は省略されます。これは条件に応じてある範囲からデータを的確に抽出するために使われます。

 

例 1

例 2

 

if

The if function either selects one of two values based on a specified condition, or proceeds along a series of calculations bases on a specified condition.

Syntax

if(condition,true value,false value)

The true value and false value arguments can be any scalar or range. For a true condition, the true value is returned; for a false condition, the false value is returned.

If the false value argument is omitted, a false condition returns a missing value. If the condition argument is scalar, then the entire true value or false value argument is returned.

If the condition argument contains a range, the result is a new range. For each true entry in the condition range, the corresponding entry in the true value argument is returned. For a false entry in the condition range, the corresponding entry in false value is returned.

If the false value is omitted and the condition entry is false, the corresponding entry in the true value range is omitted. This can be used to conditionally extract data from a range.

Example 1

The operation col(2) = if(col(1)< 75,”FAIL","PASS") reads in the values from column 1, and places the word “FAIL” in column 2 if the column 1 value is less than 75, and the word “PASS” if the value is 75 or greater.

Example 2

For the operation y = if(x < 2 or x > 4,99,x), an x value less than 2 or greater than 4 returns a y value of 99, and all other x values return a y value equal to the corresponding x value.

If you set x = {1,2,3,4,5}, then y is returned as {99,2,3,4,99}. The condition was true for the first and last x range entries, so 99 was returned. The condition was false for x = 2, 3, and 4, so the x value was returned for the second, third, and fourth x values.

 

前のページにもどる