-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayTimeView.m
45 lines (35 loc) · 1019 Bytes
/
ArrayTimeView.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
44
45
classdef ArrayTimeView < Core
properties (SetAccess = protected)
parent;
data;
times;
fs;
end
methods
function this=ArrayTimeView(parent,data,times,fs)
this.parent = parent;
this.data = data;
this.times = times;
this.fs = fs;
end
function varargout = subsref(this,s)
if strcmp(s(1).type,'()') % called
idx = s(1).subs;
len = this.fs*this.parent.sort_key__; % number of samples in an interval
% find the first interval break and save it as the onset
onset = find(mod(this.times(1:len),this.parent.sort_key__)==0);
% loop through the indices and select the given time interval
strt = onset+(idx-1)*len;
[x1,x2]=ndgrid(strt,1:len);
varargout = { this.data(x1+x2), this.parent.starttime + strt };
% passthrough to methods and properties
elseif ismethod(this,s(1).subs) || isprop(this,s(1).subs)
if length(s)>1
varargout = {this.(s(1).subs)(s(2).subs{:})};
else
varargout = {this.(s(1).subs)};
end
end
end
end
end