Findindx: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Bob No edit summary |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Finds the index of the array element closest to value | Finds the index of the array element closest to chosen value. | ||
===Synopsis=== | ===Synopsis=== | ||
Line 10: | Line 9: | ||
===Description=== | ===Description=== | ||
Inputs are an array of values | Inputs are an array of values <tt>array</tt> and a value to locate <tt>r</tt>. Output <tt>index</tt> is the linear index into <tt>array</tt> which will return the closest value to <tt>r</tt>. | ||
====Inputs==== | |||
* '''array''' = input data array. | |||
* '''r''' = target value. | |||
====Outputs==== | |||
* '''index''' = linear index into <tt>array</tt> that returns the closest value to <tt>r</tt>. | |||
===Examples=== | ===Examples=== | ||
<pre> | |||
index = findindx(array,r); %get an index | index = findindx(array,r); %get an index | ||
nearest_value = array(index); %find the value | nearest_value = array(index); %find the value | ||
</pre> | |||
===See Also=== | ===See Also=== | ||
[[lamsel]] | [[lamsel]] |
Latest revision as of 12:00, 9 October 2008
Purpose
Finds the index of the array element closest to chosen value.
Synopsis
- index = findindx(array,r)
Description
Inputs are an array of values array and a value to locate r. Output index is the linear index into array which will return the closest value to r.
Inputs
- array = input data array.
- r = target value.
Outputs
- index = linear index into array that returns the closest value to r.
Examples
index = findindx(array,r); %get an index nearest_value = array(index); %find the value