MATLAB: Simple wild card function for ismember?

ismemberMATLABwild card

I have a list of dates and times as string values and (e.g '29/1/2010 20:30:00' etc) and I would like to find all values at a specific time, regardless of day.
Is there a simple wild card function that I can use with ismember to identify these? I have tried:
idx = ismember(Timestamp_str, {'*20:30:00'});
I have also tried regexp, searched the web and help files to no avail…..

Best Answer

No, there is no wildcard with ismember.
If your Timestamp_str is an array of characters all the same length, then
strcmp(cellstr(Timestamp_str(:,end-7:end)),'20:30:00')
If your Timestamp_str is a cell array of characters, then
cellfun(@(S) strcmp(S(end-7:end),'20:30:00'), Timestamp_str)
Alternately with regexp,
~cellfun(@isempty,regexp(Timestamp_str, '20:30:00$'))
If you just want the true/false of whether there was a match or not. The regexp itself will return the index of the trailing 23:30:00 in each string, with an empty cell for cell entries that do not match.