Find certain cells with keyword

Hello Imagine I have a matrix containing a column of files name,like this: wte-142-9 wte-111-1 wte-142-1 wte-123-09 wte-142-6
I want to use some scripts to help me just extract for example cell with common keyword '142' and the output will be: wte-142-9 wte-142-1 wte-142-6 Thank you

 Accepted Answer

S = {'wte-142-9', 'wte-111-1', 'wte-142-1', 'wte-123-09', 'wte-142-6'};
M = S(contains(S, '-142-')) % With modern Matlab versions
For older systems:
match = ~cellfun('isempty', strfind(S, '-142-'));
M = S(match)

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 30 Aug 2017

Commented:

on 30 Aug 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!