-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinDiscStimulusEnsemble.m
53 lines (39 loc) · 1.79 KB
/
LinDiscStimulusEnsemble.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
46
47
48
49
50
51
52
53
classdef LinDiscStimulusEnsemble < DiscreteStimulusEnsemble
properties
circular = false;
end
methods
function obj = LinDiscStimulusEnsemble(varargin)
% superclass constructor
obj = obj@DiscreteStimulusEnsemble();
switch nargin
case 0
% do nothing
case 1
obj.ensemble = double(varargin{1});
obj.pS = 1.0 ./ double(obj.n) .* ones(1, obj.n);
case 2
obj.ensemble = double(varargin{1});
obj.pS = double(varargin{2});
assert(all(size(obj.ensemble) == size(obj.pS)), 'Ensemble value and probability arrays must be the same size')
case 4
bottom = double(varargin{1});
top = double(varargin{2});
interval = double(varargin{3});
shift = double(varargin{4});
assert(top > bottom, 'Upper limit must be greater than lower limit')
assert(interval > 0 && interval <= (top - bottom), 'Invalid interval value')
assert(mod(top - bottom, interval) == 0, 'Interval must be a divisor of the range')
assert(shift >= 0 && shift < interval, 'Invalid shift value')
if shift == 0.0
obj.ensemble = bottom : interval : (top - interval);
else
obj.ensemble = (bottom + shift) : interval : top;
end
obj.pS = 1.0 ./ double(obj.n) .* ones(1, obj.n);
otherwise
error('Wrong number of arguments')
end
end
end
end