Function ISMEMBER indexes only the first value and leaves the rest
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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)
What is the best solution to this problem?
3 Commenti
Star Strider
il 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.
.
Risposte (1)
Bruno Luong
il 22 Apr 2022
Modificato: Bruno Luong
il 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.
3 Commenti
Bruno Luong
il 22 Apr 2022
A datetime is a time stamp; it does not have length ("whole day").
Date1 = ["01-Jan 11:22:33", "01-Jan 2:33:44" "02-Oct"];
Date2 = ["01-Jan 15:00:00", "02-Jan 2:33:44"];
x = string(datestr(datenum(Date1),"dd-mmm"))
y = string(datestr(datenum(Date2),"dd-mmm"))
ismember(x,y)
Sean de Wolski
il 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.
Vedere anche
Categorie
Scopri di più su Data Type Identification in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!