How to use dbscan for durations ?

How can I use dbscan for time durations ?
A = duration({'00:01:01'
'00:00:53'
'00:00:55'
'00:00:54'
'00:00:54'
'00:00:53'
'02:45:08'
'00:01:33'
'00:00:57'
'00:00:58'
'00:00:51'
'00:00:45'
'00:01:03'
'00:00:56'
'00:00:45'
'00:26:52'
'00:01:12'
'00:00:41'
'00:00:56'
'00:01:16'
'00:01:47'
'00:09:22'
'00:00:40'
'00:00:38'
'00:00:48'
'00:00:38'
'00:00:42'
'00:00:42'
'00:01:06'
'00:01:00'
'00:00:43'
'00:00:47'
'00:00:43'
'00:00:50'
'00:00:52'
'00:01:20'
'00:01:35'
'00:00:54'
'00:01:05'
'00:02:07'
'00:00:43'
'00:00:39'
'00:29:36'
'00:00:39'
'00:00:39'
'00:01:01'
'00:01:09'
'00:01:12'
'00:01:11'
'00:01:12'
'00:01:06'
'00:01:06'
'00:01:00'
'00:01:15'
'00:01:08'
'00:00:39'
'00:00:59'
'00:00:54'
'00:01:25'
'00:01:01'
'00:01:03'
'00:01:03'
'00:00:56'
'00:01:19'
'00:01:05'
'00:01:00'
'00:01:09'
'00:01:12'
'00:00:52'
'00:00:40'
'00:01:09'
'00:01:00'
'00:01:04'
'00:00:57'
'00:02:07'
'00:02:44'
'00:00:51'
'00:01:22'
'00:01:10'
'00:01:07'
'00:01:07'
'00:00:48'
'00:00:59'
'00:01:02'
'00:00:48'
'00:00:49'
'00:00:56'
'00:01:03'
'00:00:53'
'00:01:23'
'00:00:40'
'00:01:25'
'00:01:15'
'00:01:13'
'00:02:14'
'00:01:08'
'00:00:53'
'00:01:00'})
A = 98×1 duration array
00:01:01 00:00:53 00:00:55 00:00:54 00:00:54 00:00:53 02:45:08 00:01:33 00:00:57 00:00:58 00:00:51 00:00:45 00:01:03 00:00:56 00:00:45 00:26:52 00:01:12 00:00:41 00:00:56 00:01:16 00:01:47 00:09:22 00:00:40 00:00:38 00:00:48 00:00:38 00:00:42 00:00:42 00:01:06 00:01:00
dbscan(A)
Error using dbscan
Expected X to be one of these types:

single, double, logical

Instead its type was duration.

 Accepted Answer

As with your earlier question, convert your durations to numeric values using minutes. You can later convert it back to durations also using minutes.
A = duration('00:01:01')
A = duration
00:01:01
B = minutes(A)
B = 1.0167
C = minutes(B)
C = duration
1.0167 min
C.Format = 'hh:mm:ss'
C = duration
00:01:01

3 Comments

cool, thanks a lot!!!
...and what about
datenum('00:01:01')
ans = 7.3852e+05
?
datenum is not recommended. To represents points in time, use datetime arrays. To represent elapsed times, use duration or calendarDuration arrays. For more information on updating your code, see Version History or Replace Discouraged Instances of Serial Date Numbers and Date Strings.
Really thankful @Cris LaPierre !!!

Sign in to comment.

More Answers (0)

Categories

Asked:

Sim
on 3 Nov 2022

Commented:

Sim
on 8 Nov 2022

Community Treasure Hunt

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

Start Hunting!