function [names, subs] = varnames(strs, delimiters)
% VARNAMES Extracts the variable names from the strings.
%
% STRS is either a string or a cell array of strings.
% DELIMITERS is an (optional) array of delimiter characters.
%
% NAMES is a string or a cell array of strings containing variable names.
% SUBS  is a string or a cell array of strings containing subscripts.
%
% K(i), S.a, C{j}, ... => names: K, S, C, ...
%                      => subs : (i), .a, {j}, ...

% Copyright 2000-2023 The MathWorks, Inc.

% Default arguments
if (nargin < 2 || isempty(delimiters)), delimiters = '.({'; end

% Tokenize the string(s).
[names, subs] = strtok(strs, delimiters);

% LocalWords:  STRS
