function Value = mustBeStringVector(Value,PropName,WarnOnRepeat)
% Checks that VALUE can be converted to a string vector.
%
%   Valid inputs include 
%      * 'a', char('a','bcd') (char)
%      * "a", ["a";"b"], ["a",""] (string)
%      * {'a';'b'}, {'a',''} (cellstr)
%      * [], {}. 
%   This function returns VALUE as a string vector and returns a
%   0x1 string array when all entries of VALUE are blank.
%
%   Use this function to validate I/O names and state names.
%
%   See also: ltipack.isNameList.

%   Copyright 1986-2016 The MathWorks, Inc.
if isempty(Value)
   Value = strings(0,1);
else
   if ischar(Value) || iscellstr(Value) %#ok<*ISCLSTR>
      try %#ok<*TRYNC>
         Value = string(Value);
      end
   end
   if ~(isstring(Value) && isvector(Value))
      error(message('Control:ltiobject:setLTI3',PropName))
   end
   % Remove leading and trailing blanks
   Value = strip(Value(:));
   % Store as 0x1 string array if all unspecified, and warn if repeated names
   idx = find(Value~=""); % specified entries
   if isempty(idx)
      Value = strings(0,1);
   elseif WarnOnRepeat
      if numel(unique(Value(idx)))<numel(idx)
         warning(message('Control:ltiobject:RepeatedChannelNames'))
      end
   end
end