2%> Return a scalar MATLAB whole-number containing
3%> the length of the input scalar or vector
object.
6%> The following rules apply to computing the length:
8%> <li> If the input ``obj`` is a scalar
object of type ``
char``
9%> or ``
string`` and empty, then the output ``val`` is ``0``.
11%> <li> If the input ``obj`` is a scalar
object of type ``
char``
12%> or ``
string`` and non-empty, then the output ``val`` is ``1``.
14%> <li> If the input ``obj`` is a scalar
object of type other
15%> than ``
char`` or ``
string``, then the output ``val`` is ``1``.
16%> This is similar to the behavior of the MATLAB intrinsic ``length()``.
18%> <li> If the input ``obj`` is a vector and empty, then the output ``val`` is ``0``.
19%> This is similar to the behavior of the MATLAB intrinsic ``length()``.
21%> <li> If the input ``obj`` is a vector and non-empty,
22%> then the output ``val`` is the vector length as returned
23%> by ``length(obj)`` minus the number of empty elements.
26%> \param[in] obj : The input scalar or vector
object whose length
27%> is to returned according to the rules above.
30%> `val` : The output scalar MATLAB whole-number
31%> representing the length of the input
object.
36%> val = pm.array.len(obj);
41%> \include{lineno} example/array/
len/main.m
43%> \include{lineno} example/array/
len/main.out.m
48%> \JoshuaOsborne, May 21 2024, 4:25 PM, University of Texas at Arlington<br>
49%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
50%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
51function val =
len(obj)
55 % First ensure the input ``obj`` is a vector.
56 if numel(obj) ~= length(obj)
58 + "The input
object must be a vector." + newline ...
63 for i = 1 : length(obj)
65 if ~strcmp(
string(obj(i)), "")
function len(in obj)
Return a scalar MATLAB whole-number containing the length of the input scalar or vector object.