function ca= cellstr2str(nca)
% Convert a nested cell array to non-nested cell array.
% nca is a 1-d cell array, possibly nested, returned from a call of the
% textscan function on a string.
% If a cell in nca is a cell array storing one string, strip the inner cell
% wrapper, resulting in just that string in the cell. Other cells in nca
% remain unchanged.
% Example:
% cellstr2str( {{'abc'}, 5, -3, {'h'}, {'defg'} )
% returns
% {'abc', 5, -3, 'h', 'defg'}

ca= nca;
for k= 1:length(nca)
if iscellstr(nca{k}) % returns true if arg is a cell array of strings
ca{k}= char(nca{k}); % converts cell array of strings into char array
end
end