2%> Return the lists of values and indices of elements
3%> of the input ``strlist`` that match the input scalar
4%> (or vector of)
string(s) or integer(s)
index ``keylist``.<br>
6%> \param[in] strlist : The input scalar (or vector of) MATLAB string(s).<br>
8%> \param[in] keylist : The input scalar (or vector of) MATLAB string(s)
9%> or cell array of
char vectors or vector of MATLAB
10%> integers or a cell array of mix of the element
11%> types to match the input ``strlist``.<br>
14%> ``loclist`` : The output scalar (or vector of same size as ``keylist`` of)
15%> MATLAB integer(s) containing the location(s) of the occurrence(s)
16%> of the input ``keylist``.<br>
17%> ``namlist`` : The output scalar (or vector of same size as ``keylist`` of)
18%> MATLAB string(s) containing the
name(s) of the occurrence(s)
19%> of the input ``keylist``.<br>
24%> [loclist, namlist] = pm.str.locname(strlist, keylist)
29%> \include{lineno} example/str/
locname/main.m
31%> \include{lineno} example/str/
locname/main.out.m
36%> \JoshuaOsborne, May 21 2024, 4:38 AM, University of Texas at Arlington<br>
37%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
38%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
39function [loclist, namlist] =
locname(strlist, keylist)
41 keylistLen = pm.array.len(keylist);
42 strlist = string(strlist);
44 loclist = 1 : 1 : length(strlist);
50 strlistLen = length(strlist);
51 for i = keylistLen : -1 : 1
57 if isa(key,
"string") || isa(key,
"char")
59 for j = 1 : strlistLen
60 if strcmpi(key, strlist(j))
61 namlist(i) = strlist(j);
68 % This situation happens because of automatic conversion of numbers
69 % to strings in MATLAB array constructs like a = [
"paramonte", 1];
70 key = str2double(key);
73 failed = key < 1 || strlistLen < key;
76 namlist(i) = strlist(key);
82 failed = strlistLen < loclist(i);
84 namlist(i) = string(strlist{loclist(i)});
93 help(
"pm.str.locname");
99 +
"The element #" +
string(i) +
" of the input ``keylist`` above" + newline ...
100 +
"argument does not match any elements of the input ``strlist`` above." + newline ...
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.
function isnumeric(in str)
Return a scalar MATLAB logical that is true if and only if the input string can be converted to a sca...
function locname(in strlist, in keylist)
Return the lists of values and indices of elements of the input strlist that match the input scalar (...