function c = cellstr(s)
%MATLAB Code Generation Library Function

% Limitations:
% 1. Strings not checked for missing
% 2. Empty inputs will differ from MATLAB outputs

%   Copyright 2022 The MathWorks, Inc.
%#codegen

coder.internal.assert(ischar(s)||iscell(s), 'MATLAB:invalidConversion', 'cellstr', class(s));
if iscell(s)
    for i=1:numel(s)
        coder.internal.assert(coder.internal.isCharOrScalarString(s{i}), 'MATLAB:cellstr:MustContainText', i);
    end
end

if ischar(s)
    if isempty(s)
        c = {''};
    else
        coder.internal.assert(ismatrix(s), 'MATLAB:cellstr:InputShape');
        numrows = size(s,1);
        c = cell(numrows,1);
        for i = 1:numrows
            c{i} = deblank(s(i,:));
        end
    end
elseif iscellstr(s) %#ok<ISCLSTR>
    c = s;
elseif iscell(s)
    c = cell(size(s));
    for i=1:numel(c)
        if ischar(s{i})
            c{i} = s{i};
        else % if isstring(s{i}) && isscalar(s{i})
            c{i} = char(s{i});
        end
    end
end
