22 lines
659 B
Matlab
22 lines
659 B
Matlab
function n = strlength (s)
|
|
%STRLENGTH Number of characters in each element of text (MATLAB R2016b+).
|
|
%
|
|
% An owuitools compatibility shim; see contains.m for the policy.
|
|
% MATLAB returns a double array shaped like its input, and 0 for the
|
|
% empty string. With char input it counts the characters, which is what
|
|
% `numel` does here - the difference only shows up for cell input.
|
|
|
|
if (nargin < 1)
|
|
error ('strlength: not enough input arguments');
|
|
end
|
|
if (ischar (s))
|
|
n = numel (s);
|
|
return;
|
|
end
|
|
c = owuitools_text_cell (s, 'strlength', 'str');
|
|
n = zeros (size (c));
|
|
for k = 1:numel (c)
|
|
n(k) = numel (c{k});
|
|
end
|
|
end
|