www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConvertStringArrayToCellArrayExample.m
%% Convert String Array to Cell Array % Starting in R2016b, you can create string arrays using the |string| % function. However, you might need to use functions that accept cell % arrays of character vectors as input arguments, and that do not accept % string arrays. To pass data from a string array to such functions, use the % |cellstr| function to convert the string array to a cell array of character % vectors. % % Create a string array. S = string('Past'); S(2) = 'Present'; S(3) = 'Future' %% class(S) %% % Convert the string array to a 1-by-3 cell array of character vectors. C = cellstr(S) %% class(C) %% % Text processing functions (such as |strfind| and |regexp|) accept string % arrays as inputs, but other functions (for example, |addpath|) do not.