Programmer Guide/Command Reference/EVAL/limit: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 5: Line 5:
:'''<code>limithigh(<var>x</var>, <var>hi</var>)</code>'''
:'''<code>limithigh(<var>x</var>, <var>hi</var>)</code>'''
:;<var>x</var>: a scalar, vector or matrix
:;<var>x</var>: a scalar, vector or matrix
:;<var>lo</var>: lower boundary, must be a scalar
:;<var>lo</var>: lower boundary, must be a number
:;<var>hi</var>: upper boundary, must be a scalar
:;<var>hi</var>: upper boundary, must be a number
;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''.
;Result: The result ''r'' is a copy of ''x'' but the values of the elements of r are limited to the boundaries defined by ''lo'' and/or ''hi''.
::''r''<sub>i,j</sub> is set to ''lo'' if x
::''r''<sub>i,j</sub> is set to ''lo'' if x<sub>i,j</sub> is lower than ''lo'' (functions '''limit''' and '''limitlow''')
::<code>''r''[i] = ''yl''{[''i'']}</code> if <code>''x''[''i''] <= ''t''{[''i'']}</code> and
::''r''<sub>i,j</sub> is set to ''hi'' if x<sub>i,j</sub> is greater than ''hi'' (functions '''limit''' and '''limithigh''')
::<code>''r''[i] = ''yh''{[''i'']}</code> if <code>''x''[''i''] > ''t''{[''i'']}</code>
;See also: [[../vsubc|vsubc]], [[../select|select]], [[../#Selection operator|conditional assignment "? :"]]
:The result r has the same length as ''x''.
 
[[../#Functions|<function list>]]


;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]], [[Programmer_Guide/Command_Reference/EVAL/limit|limit, limitlow, limithigh]]


Example:
Example:
Line 19: Line 19:
#a := eval vv(1,2,3,4,5,4,3,2,1)
#a := eval vv(1,2,3,4,5,4,3,2,1)
#b := eval fill(9,0,1)
#b := eval fill(9,0,1)
#c := eval select($#a,3,0,$#a)
#c := eval limitlow($#a, 3)
// -> $#c = { 0 , 0 , 0 , 4 , 5 , 4 , 0 , 0 , 0 }  
// -> $#c = { 3 , 3 , 3 , 4 , 5 , 4 , 3 , 3 , 3 }  
#d := eval select($#a, $#b , $#b , $#a)
#d := eval limit($#b, 2, 6)
// -> $#d = { 1 , 2 , 3 , 4 , 5 , 5 , 6 , 7 , 8 }
// -> $#d[*,0] = { 2 , 2 , 3 , 4 , 5 , 4 , 3 , 2 , 2 }
#e := eval select($#b%2, 0, $#b, -1)
//   $#d[*,1] = { 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 }
// -> $#d = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 }
</pre>
</pre>
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
=====limit=====
Limit the input values to a particular range of values.
=====Usage:=====
<code>limit(<var>val</var>, <var>lo</var>, <var>hi</var>)</code>
=====Function:=====
Limit the <var>val</var> values to the range of values between lo and hi (<var>lo</var><=<var>val</var><code><=</code><var>hi</var>). VAlues outside the range are set to the boundary values.
=====Parameters:=====
;<var>val</var>
:The input scalar, vector or matrix.
;<var>lo</var>
:The lower boundary scalar.
;<var>hi</var>
:The upper boundary scalar.

Latest revision as of 11:10, 21 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 number
hi
upper boundary, must be a number
Result
The result r is a copy of x but the values of the elements of r are limited to the boundaries defined by lo and/or hi.
ri,j is set to lo if xi,j is lower than lo (functions limit and limitlow)
ri,j is set to hi if xi,j is greater than hi (functions limit and limithigh)
See also
vsubc, select, conditional assignment "? :"

<function list>


Example:

#a := eval vv(1,2,3,4,5,4,3,2,1)
#b := eval fill(9,0,1)
#c := eval limitlow($#a, 3)
// -> $#c = { 3 , 3 , 3 , 4 , 5 , 4 , 3 , 3 , 3 } 
#d := eval limit($#b, 2, 6)
// -> $#d[*,0] = { 2 , 2 , 3 , 4 , 5 , 4 , 3 , 2 , 2 }
//    $#d[*,1] = { 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 }

Navigation menu

Personal tools