# how to convert absolute time to real time and calculate the sampling rate

19 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Les Beckham
on 25 Oct 2023

Edited: Les Beckham
on 25 Oct 2023

load metaData_Depth

fn = @(s) datetime(s.AbsTime);

dt = arrayfun(fn, metaData_Depth)

delta_t = seconds(diff(dt))

max(delta_t)

min(delta_t)

numel(unique(delta_t))

mean(delta_t)

std(delta_t)

plot(delta_t, '.')

grid on

So, every single sample has a different duration of time between it and the next sample. Thus, it isn't going to make much sense to calculate a sample rate for this data.

##### 7 Comments

Voss
on 25 Oct 2023

load metaData_Depth

C = num2cell(vertcat(metaData_Depth.AbsTime),1);

dt = datetime(C{:})

delta_t = dt - dt(1)

### More Answers (0)

### See Also

### Community Treasure Hunt

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

Start Hunting!