| DSP Blockset | Search  Help Desk |
| Variable Integer Delay | See Also |
Delay the input by a time-varying integer number of sample periods.
Library
Signal Operations, in General DSPDescription
The Variable Integer Delay block delays the discrete-time input at the top (In) port by the integer number of sample intervals specified by the input to the bottom (Delay) port. Both ports must have the same rate. The delay for a sample-based input sequence is a scalar value by which to uniformly delay every channel. The delay for a frame-based input sequence can be a scalar value by which to uniformly delay every sample in every channel, or a vector containing one delay value for each sample in the input frame.
The delay values should be in the range of 0 to D, where D is the Maximum delay in samples. Delay values greater than D or less than 0 are clipped to those respective values and noninteger delays are rounded to the nearest integer value.
The Variable Integer Delay block differs from the Integer Delay block in the following three ways.Sample-Based Operation
When the check box is not selected (default), the block assumes that the input is a 1-by-N sample vector or M-by-N sample matrix. Each of the N vector elements (or M*N matrix elements) is treated as an independent channel, and the block applies the delay at theDelay port to each channel.
The Variable Integer Delay block stores the D+1 most recent samples received at the In port for each channel. At each sample time the block outputs the stored sample(s) indexed by the input to the Delay port.
For example, if the input to the In port, u, is a scalar signal, the block stores a vector, U, of the D+1 most recent signal samples. If we call the current input sample U(1), the previous input sample U(2), and so on, then the block's output is
y = U(v+1); % equivalent MATLAB codewhere
v is the input to the Delay port. Note that a delay value of 0 (v=0) causes the block to pass through the sample at the In port in the same simulation step that it is received. The block's memory is initialized to the Initial conditions value at the start of the simulation (see below).
The figure below shows the block output for a scalar ramp sequence at the In port, a Maximum delay in samples of 5, an Initial conditions of 0, and a variety of different delays at the Delay port.

Note that the current input at each time-step is immediately stored in memory as U(1). This allows the current input to be available at the output for a delay of 0 (v=0).
Delay port. Both fixed and time-varying initial conditions can be specified in a variety of ways to suit the dimensions of the input sequence.
Fixed Initial Conditions.
The settings shown below specify fixed initial conditions. For a fixed initial condition, the block initializes each of D samples in memory to the value entered in the Initial conditions parameter. A fixed initial condition in sample-based mode can be specified in one of the following ways:

the block initializes 100 M-by-N matrices in memory with zeros. A scalar initial condition can be used with input sequences of any dimension.
ic, is reshaped columnwise to match the input matrix dimensions.
y = reshape(ic,M,N) % equivalent MATLAB code
For a 2-by-3 input and the parameters below,

the block initializes 100 2-by-3 matrices in memory with
An initial condition of length M*N can be used with input sequences of any dimension, and can be specified as either a row or column vector.

the block initializes 100 2-by-3 matrices in memory with
For cases where M=N=1 or M=1, the initial condition setting reduces to a scalar or a vector, described above.
U(2:D+1), where D is the Maximum delay in samples. For a scalar input and the parameters shown below,

the block initializes U(2:6) with values [-1, -1, -1, 0, 1]. A length-D vector initial condition can only be used with scalar inputs.
U(2:D+1), where M is the length of the input vector, and D is the Maximum delay in samples. For a 1-by-3 input and the parameters below,

the block initializes memory locations U(2:6) with values
U(2) = [1 -1 0] U(3) = [2 -2 0] U(4) = [3 -3 0] U(5) = [4 -4 0] U(6) = [5 -5 0]
A matrix initial condition can only be used with vector inputs.
U(2:D+1), where D is the Maximum delay in samples and M and N are the number of rows and columns, respectively, in the input matrix. For a 2-by-3 input and the parameters below,

the block initializes memory locations U(2:5) with values
An array initial condition can only be used with matrix inputs.
Frame-Based Operation
When the Frame-based inputs check box is selected, the block assumes that the input is an M-by-N frame matrix. Each of the frames in the matrix contains M sequential time samples from an independent channel. The illustration below shows a 6-by-4 matrix input:
The Number of channels parameter specifies the number of independent channels (columns), N, in the matrix.
In frame-based mode, the input at the Delay port can be a scalar value by which to uniformly delay every sample in every channel, or length-M vector, v = [v(1) v(2) ... v(M)], containing one delay for each sample in the input frame(s). The set of delays contained in vector v is applied identically to every channel of a multichannel input.
Vector v does not specify when the samples in the current input frame will appear in the output. Rather, v indicates which previous input samples (stored in memory) should be included in the current output frame. The first sample in the current output frame is the input sample v(1) intervals earlier in the sequence, the second sample in the current output frame is the input sample v(2) intervals earlier in the sequence, and so on.
The illustration below shows how this works for an input with a sample period of 1 and frame size of 4. The Maximum delay in samples (Dmax) is 5, and the Initial conditions parameter is set to -1. The delay input changes from [1 3 0 5] to [2 0 0 2] after the second input frame. Note that the samples in each output frame are the values in memory indexed by the elements of v.
y(1) = U(v(1)+1) y(2) = U(v(2)+1) y(3) = U(v(3)+1) y(4) = U(v(4)+1)

Frame-based operation provides substantial increases in throughput rates at the expense of greater model latency.
The Initial conditions parameter specifies the values in the block's memory at the start of the simulation. Both fixed and time-varying initial conditions can be specified. Fixed Initial Conditions. The settings shown below specify fixed initial conditions. For a fixed initial condition, the block initializes each of D samples in memory to the value entered in the Initial conditions parameter. A fixed initial condition in frame-based mode can be one of the following:

the block initializes the six samples in memory with zeros.

the block the block initializes each of five samples in memory to [0 -1]. If the input frame size is specified to be 1, then this operation is equivalent to the sample-based operation described above.
U(2:D+1), is initialized with the D columns of the matrix.
For a two-channel input with a frame size of 4 and the parameter settings below,

the block initializes memory locations U(2:6) with values
U(2) = [0 -1] U(3) = [0 -2] U(4) = [0 -3] U(5) = [0 -4] U(6) = [0 -5]
If the input frame size is specified to be 1, then this operation equivalent to the sample-based operation described above.
NoteDialog Box

See Also
Integer Delay