%% Detect Text at Start of String
% Create a string array that contains file names. Determine which file names start with the word data.
% Starting in R2017a, you can create strings using double quotes.

str = ["abstract.docx","data.tar","code.m"; ...
       "data-analysis.ppt","results.ptx","summary.ppt"]

%
% If you are using R2016b, create string arrays using the string function instead of double quotes.
% Return a logical array where the position of each element equal to 1 corresponds to the position of a string in str that starts with data.

pat = "data";
TF = startsWith(str,pat)

%
% Display the file names that start with data. Index back into str using TF.

str(TF)

% Copyright 2012-2020 The MathWorks, Inc.