samer@34
|
1 function x=blockdata(gen,dur,s0,varargin)
|
samer@34
|
2 % blockdata - Signal as a sequence of blocks from signal generator object
|
samer@34
|
3 %
|
samer@34
|
4 % blockdata ::
|
samer@34
|
5 % gen(A,B{1:N}) ~'signal generator object with state A and N params B',
|
samer@34
|
6 % seq(natural) ~'number of samples to generate in each block',
|
samer@34
|
7 % A ~'initial state',
|
samer@34
|
8 % seq(B{1}) ~'sequence of 1st param values',
|
samer@34
|
9 % ...
|
samer@34
|
10 % seq(B{N}) ~'sequence of Nth param values',
|
samer@34
|
11 % -> seq([[1,_]]) ~'heterogenous sequence of arrays'.
|
samer@34
|
12 %
|
samer@34
|
13 % The main point of this construct is to maintain state
|
samer@34
|
14 % between calls to the block method of the signal generator, and
|
samer@34
|
15 % also to supply the generator with a sequence of parameter
|
samer@34
|
16 % values.
|
samer@34
|
17
|
samer@34
|
18 nargs=length(varargin)+1;
|
samer@34
|
19 params=cellmap(@dd,varargin); % make sure all input sequences actually are
|
samer@34
|
20 perm=[nargs+1,1,2:nargs];
|
samer@36
|
21 x=zipaccum(@blockgen,s0,dd(dur),params{:});
|
samer@34
|
22
|
samer@34
|
23 function [y,state]=blockgen(varargin)
|
samer@34
|
24 % this is weird - for some reason Matlab crashes if I call block
|
samer@34
|
25 % directly from here, but is ok if I go via the non-nested bblock
|
samer@34
|
26 [y,state]=bblock(gen,varargin{perm});
|
samer@34
|
27 end
|
samer@34
|
28
|
samer@34
|
29 % function y=blockgen_nostate(theta)
|
samer@34
|
30 % y=block(gen,s0,ceil(theta{1}),theta{2:end});
|
samer@34
|
31 % end
|
samer@34
|
32 end
|
samer@34
|
33
|
samer@34
|
34 function [y,s]=bblock(varargin)
|
samer@34
|
35 [y,s]=block(varargin{:});
|
samer@34
|
36 end
|
samer@34
|
37
|