Repository navigation
Expand file tree
/
Copy pathhist.m
More file actions
62 lines (49 loc) · 1.28 KB
/
Copy pathhist.m
File metadata and controls
62 lines (49 loc) · 1.28 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
% SIG.HIST
%
% 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 = hist(varargin)
varargout = sig.operate('sig','hist',...
initoptions,@init,@main,@after,varargin);
end
%%
function options = initoptions
n.key = 'Number';
n.type = 'Numeric';
n.default = 10;
options.n = n;
end
%%
function [x type] = init(x,option,frame)
type = 'sig.signal';
end
function out = main(in,option)
x = in{1};
if ~strcmpi(x.yname,'Histogram')
res = sig.compute(@routine,x.Ydata,option.n);
x = sig.signal(res,'Name','Histogram',...
'Xsampling',1,'Xstart',1,...res{2},...
'Srate',x.Frate,'Ssize',x.Ssize);
end
out = {x};
end
function out = routine(d,nbins)
if ~isempty(find(strcmp('element',d.dims),1)) && d.size('element') > 1
dim = 'element';
else
dim = 'sample';
end
out = d.apply(@algo,{nbins},{dim},1);
if strcmp(dim,'sample')
out = out.deframe;
end
end
function [n, xout] = algo(x,nbins)
[n xout] = hist(x,nbins);
n = n';
end
function x = after(x,option)
end