Function ISMEMBER indexes only the first value and leaves the rest

5 views (last 30 days)
I'm having a problem with the () function, as it indexes the first value and leaves the duplicate values, the code below is in the figure and the table as well:
x = datetime(Date1,"Format","dd-MMM")
y = datetime(Date2,"Format","dd-MMM")
idx = ismember(x,y)
Input DataInput Data
What is the best solution to this problem?
Star Strider
Star Strider on 22 Apr 2022
That does not change the underlying data. Everything else is still there, since the 'Format' name-value pair only changes the display.

Sign in to comment.

Answers (1)

Bruno Luong
Bruno Luong on 22 Apr 2022
Edited: Bruno Luong on 22 Apr 2022
ismember returns in the first argument the logical array, not the index. If you want the firs index (idx will be empty if there is no x in y)
idx = find(ismember(x,y),1,'first')
PS: your screen shot shows xx and yy not x and y.
Sean de Wolski
Sean de Wolski on 22 Apr 2022
I want to extend the date for the whole day (24hours) instead pf only the start hour of the day..
In that case, you should dateshift the timestamp to the start or end of the day so that you can then aggregate by day.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!