ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
index.m
Go to the documentation of this file.
1%> \brief
2%> Given ``array(1 : n)``, return the array index ``indx(1 : n)``
3%> such that ``array(indx)`` is in ascending order.<br>
4%>
5%> \details
6%> This is a simple convenience wrapper around
7%> the MATLAB intrinsic function ``sort()``.<br>
8%>
9%> \note
10%> Beware the output ``indx`` is **not** the
11%> rank of the elements of the input array.<br>
12%>
13%> \param[in] array : The input MATLAB vector of sortable values
14%> (that can be passed to the MATLAB intrinsic function ``sort()``).<br>
15%>
16%> \return
17%> ``indx`` : The output MATLAB integer vector of the same size as the
18%> input ``array`` such that ``array(indx)`` is in ascending order.<br>
19%>
20%> \interface{index}
21%> \code{.m}
22%>
23%> indx = pm.sort.index(array)
24%>
25%> \endcode
26%>
27%> \example{index}
28%> \include{lineno} example/sort/index/main.m
29%> \output{index}
30%> \include{lineno} example/sort/index/main.out.m
31%>
32%> \final{index}
33%>
34%> \author
35%> \JoshuaOsborne, May 21 2024, 3:55 AM, University of Texas at Arlington<br>
36%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
37%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
38function indx = index(array)
39 [~, indx] = sort(array);
40end
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.