-
Notifications
You must be signed in to change notification settings - Fork 0
/
tranter_ts.m
43 lines (34 loc) · 1.13 KB
/
tranter_ts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [series] = tranter_ts(interpolate)
% TRANTER_TS Generates timeseries objects from tranter_table()
% OUT:
% Array of timeseries objects
% set default value
if ~exist('interpolate', 'var')
interpolate = false;
end
% fetch Tranter's correction table
[table, hours, fitness] = tranter_table();
% get number of series and preallocate timeseries array
num_series = size(table, 1);
series = repmat(timeseries(), num_series, 1);
% generate timeseries from data table
for i = 1:num_series
% cache data
t_row = table(i, :);
h = hours; % convert to seconds
f = fitness(i);
% build timeseries
ts = timeseries(t_row, h, ...
'name', ['Corrected time (hours) for fitness = ' num2str(f)]);
ts.UserData = f;
ts.TimeInfo.Units = 'hours';
ts.TreatNaNasMissing = true;
% resample timeseries if requested
if interpolate
ts = resample(ts, hours(1):1:hours(end));
end
% register series with array
series(i) = ts;
end
plot(series(3));
end