I have directory names that end in '0.0100'. I want to be able to skip certain directories by comparing the substring '0.0100' to the directory name. How can I do this?
You can use the 'contains' function to determine whether a string contains a given substring or not. Specifically, 'contains' returns true if the first argument contains the second argument and false otherwise. For example:
>> smallSubstring = '0.0100';
>> largeString1 = 'Item0.0100';
>> largeString2 = 'Item0.0101';
>> contains(largeString1, smallSubstring)
ans =
logical
1
>> contains(largeString2, smallSubstring)
ans =
logical
0
You may find more information about 'contains' at the following documentation page:
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
1 Comment
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/345593-how-can-i-determine-whether-a-string-contains-a-substring#comment_723909
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/345593-how-can-i-determine-whether-a-string-contains-a-substring#comment_723909
Sign in to comment.