Programmer Guide/Command Reference/EVAL/limit: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
m (1 revision: Initial import) |
No edit summary |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{ | {{DISPLAYTITLE:limit, limitlow, limithigh}} | ||
Limit the values of argument ''x'' to a particular range of values. | |||
;Usage: '''<code>limit(<var>x</var>, <var>lo</var>, <var>hi</var>)</code>''' | |||
:'''<code>limitlow(<var>x</var>, <var>lo</var>)</code>''' | |||
:'''<code>limithigh(<var>x</var>, <var>hi</var>)</code>''' | |||
:;<var>x</var>: a scalar, vector or matrix | |||
:;<var>lo</var>: lower boundary, must be a scalar | |||
:;<var>hi</var>: upper boundary, must be a scalar | |||
;Result: The result r has the same type as ''x'' but the values of r are limited to the boundaries defined by ''lo'' and ''hi''. | |||
::''r''<sub>i,j</sub> is set to ''lo'' if x | |||
::<code>''r''[i] = ''yl''{[''i'']}</code> if <code>''x''[''i''] <= ''t''{[''i'']}</code> and | |||
::<code>''r''[i] = ''yh''{[''i'']}</code> if <code>''x''[''i''] > ''t''{[''i'']}</code> | |||
:The result r has the same length as ''x''. | |||
;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]], [[Programmer_Guide/Command_Reference/EVAL/limit|limit, limitlow, limithigh]] | |||
Example: | |||
<pre> | |||
#a := eval vv(1,2,3,4,5,4,3,2,1) | |||
#b := eval fill(9,0,1) | |||
#c := eval select($#a,3,0,$#a) | |||
// -> $#c = { 0 , 0 , 0 , 4 , 5 , 4 , 0 , 0 , 0 } | |||
#d := eval select($#a, $#b , $#b , $#a) | |||
// -> $#d = { 1 , 2 , 3 , 4 , 5 , 5 , 6 , 7 , 8 } | |||
#e := eval select($#b%2, 0, $#b, -1) | |||
// -> $#d = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 } | |||
</pre> | |||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | |||
=====limit===== | =====limit===== | ||
Revision as of 13:01, 6 April 2011
Limit the values of argument x to a particular range of values.
- Usage
limit(x, lo, hi)
limitlow(x, lo)
limithigh(x, hi)
- x
- a scalar, vector or matrix
- lo
- lower boundary, must be a scalar
- hi
- upper boundary, must be a scalar
- Result
- The result r has the same type as x but the values of r are limited to the boundaries defined by lo and hi.
- ri,j is set to lo if x
r[i] = yl{[i]}
ifx[i] <= t{[i]}
andr[i] = yh{[i]}
ifx[i] > t{[i]}
- The result r has the same length as x.
- See also
- vsubc, limit, limitlow, limithigh
Example:
#a := eval vv(1,2,3,4,5,4,3,2,1) #b := eval fill(9,0,1) #c := eval select($#a,3,0,$#a) // -> $#c = { 0 , 0 , 0 , 4 , 5 , 4 , 0 , 0 , 0 } #d := eval select($#a, $#b , $#b , $#a) // -> $#d = { 1 , 2 , 3 , 4 , 5 , 5 , 6 , 7 , 8 } #e := eval select($#b%2, 0, $#b, -1) // -> $#d = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 }
Contents
limit
Limit the input values to a particular range of values.
Usage:
limit(val, lo, hi)
Function:
Limit the val values to the range of values between lo and hi (lo<=val<=
hi). VAlues outside the range are set to the boundary values.
Parameters:
- val
- The input scalar, vector or matrix.
- lo
- The lower boundary scalar.
- hi
- The upper boundary scalar.