Repository navigation
Expand file tree
/
Copy pathlength.m
More file actions
68 lines (52 loc) · 1.41 KB
/
Copy pathlength.m
File metadata and controls
68 lines (52 loc) · 1.41 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% SIG.LENGTH
% indicates the temporal length of x.
%
% Copyright (C) 2017, Olivier Lartillot
%
% All rights reserved.
% License: New BSD License. See full text of the license in LICENSE.txt in
% the main folder of the MiningSuite distribution.
function varargout = length(varargin)
varargout = sig.operate('sig','length',options,...
@init,@main,@after,varargin,@sum);
end
function options = options
options = sig.signal.signaloptions();
unit.key = 'Unit';
unit.type = 'String';
unit.choice = {'Second','Sample'};
unit.default = 'Second';
options.unit = unit;
end
function [x type] = init(x,option,frame)
type = 'sig.signal';
end
function out = main(in,option)
x = in{1};
res = sig.compute(@routine,x.Ydata,x.Srate,option);
out = {sig.signal(res,'Name','Length','Srate',0,'Ssize',1,...
'FbChannels',x.fbchannels)};
end
function out = routine(d,sr,option)
e = d.apply(@algo,{sr,option},{'sample'},1);
out = {e};
end
function l = algo(d,sr,option)
if iscell(d)
nsg = length(s);
l = zeros(nsg,1);
for i = 1:nsg
l(i) = length(s{i});
end
else
l = length(d);
end
if strcmp(option.unit,'Second')
l = l./sr;
end
end
function x = after(x,option)
end
function x = sum(x,y)
x.Ydata.content = x.Ydata.content + y.Ydata.content;
end