MATLAB: Pick one value per munite

time

Hi all,
i have such an date time Array:
'18-May-2016 14:04:17'
'18-May-2016 14:05:07'
'18-May-2016 14:05:54'
'18-May-2016 14:06:43'
'18-May-2016 14:07:34'
'18-May-2016 14:08:25'
'18-May-2016 14:09:15'
'18-May-2016 14:10:07'
'18-May-2016 14:10:57'
'18-May-2016 14:11:48'
'18-May-2016 14:12:39'
'18-May-2016 14:13:30'
'18-May-2016 14:14:22'
'18-May-2016 14:15:12'
'18-May-2016 14:16:03'
'18-May-2016 14:16:54'
how could i clear the repeated munite values? for exemple : 18-May-2016 14:05:54 , '18-May-2016 14:10:07' and '18-May-2016 14:16:54'.
Thank you all

Best Answer

To start with, I would convert the datestr array to datetime and just work with that for the rest of your code.
To perform the filtering, you use unique as per Azzi's answer:
A={'18-May-2016 14:04:17'
'18-May-2016 14:05:07'
'18-May-2016 14:05:54'
'18-May-2016 14:06:43'
'18-May-2016 14:07:34'
'18-May-2016 14:08:25'
'18-May-2016 14:09:15'
'18-May-2016 14:10:07'
'18-May-2016 14:10:57'
'18-May-2016 14:11:48'
'18-May-2016 14:12:39'
'18-May-2016 14:13:30'
'18-May-2016 14:14:22'
'18-May-2016 14:15:12'
'18-May-2016 14:16:03'
'18-May-2016 14:16:54'}
A = datetime(A); %convert to datetime. In your cases, datetime is clever enough that you don't even need to specify the format
[~, indextokeep] = unique(A.Minute); %see how easy it is to extract the minutes
filteredA = A(indextokeep)
Related Question