2%> Return the starting
index of the first occurrence
3%> of the input scalar MATLAB
string ``pattern`` in
4%> the input scalar MATLAB
string ``str``, otherwise,
5%>
return ``0`` to indicate the lack of the ``pattern``
6%> in the input ``str``.<br>
9%> This function partially replicates the functionality
10%> of the Fortran intrinsic function ``
index()``.<br>
11%> This function uses the MATLAB intrinsic ``strfind()``
12%> to achieve the goal. However, unlike ``strfind()``
13%> it always returns a number such that the function
14%> can be directly used in
string slicing.<br>
16%> \param[in] str : The input scalar MATLAB
string to be searched
17%>
for the presence of the input pattern.<br>
18%> \param[in] pattern : The input scalar MATLAB
string to be
19%> searched
for within the input ``str``.<br>
22%> ``loc`` : The output scalar MATLAB integer
23%> containing the location of the first occurrence of the
24%> input ``pattern`` in the input ``str`` or ``0``
if no such
30%> loc = pm.str.index(str, pattern)
35%> \include{lineno} example/str/
index/main.m
37%> \include{lineno} example/str/
index/main.out.m
42%> \JoshuaOsborne, May 21 2024, 4:34 AM, University of Texas at Arlington<br>
43%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
44%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
45function loc =
index(str, pattern)
46 loc = strfind(str, pattern);
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.