dsp.VariableFractionalDelay
Delay input by time-varying fractional number of sample periods
Description
The dsp.VariableFractionalDelay
System object™ delays the input signal by a specified number of fractional samples along each
channel of the input. The object can also concurrently compute multiple delayed versions
(taps) of the same signal. For an example, see Signal Delay Using Multitap Fractional Delay.
The object interpolates the input signal to obtain new samples at noninteger sampling
intervals. You can set the InterpolationMethod property to 'Linear'
,
'FIR'
, or 'Farrow'
. The object supports time-varying
delay values. That is, the delay value can vary within a frame from sample to sample. You can
also specify the maximum value of the delay by using the MaximumDelay
property. Delay values greater than the maximum are clipped to the maximum.
To delay the input by a time-varying fractional number of sample periods:
Create the
dsp.VariableFractionalDelay
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Description
creates a
variable fractional delay System object that delays a discrete-time input by a time-varying fractional number of
sample periods, as specified by the second input.vfd
= dsp.VariableFractionalDelay
creates a variable fractional delay System object with each specified property set to the specified value. Enclose each
property name in single quotes.vfd
= dsp.VariableFractionalDelay(Name,Value
)
Example: dsp.VariableFractionalDelay('MaximumDelay',50);
Properties
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release
function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
InterpolationMethod
— Method of interpolation
'Linear'
(default) | 'FIR'
| 'Farrow'
Method of interpolation, specified as one of the following. Using this method, the object interpolates the signal to obtain new samples at noninteger sampling intervals.
'Linear'
–– The object uses linear interpolation.'FIR'
–– The object implements a polyphase FIR interpolation filter to interpolate values.'Farrow'
–– The object uses the LaGrange method to interpolate values.
For more details on these methods, see Algorithms.
FilterHalfLength
— Half-length of FIR interpolation filter
4
(default) | positive integer in the range [1 65535]
Half-length of FIR interpolation filter, specified as a positive integer in the range [1 65535].
For periodic signals, a larger value of this property, which indicates a higher order filter, yields a better estimate of the delayed output sample. A property value of 4 to 6, which corresponds to a 7th-order to 11th-order filter, is usually adequate.
Dependencies
This property applies only when you set the InterpolationMethod property to
'FIR'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| fi
FilterLength
— Length of Farrow filter
4
(default) | integer greater than or equal to 2
Length of the FIR filter implemented using the Farrow structure, specified as an integer greater than or equal to 2. If the length equals 2, the filter performs linear interpolation. The filter length value determines the order of the polynomial used for lagrange interpolation.
Example: 4
Example: 10
Dependencies
This property applies only when you set the InterpolationMethod property to
'Farrow'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
InterpolationPointsPerSample
— Number of interpolation points per input sample
10
(default) | positive integer in the range [2, 65,535]
Number of interpolation points per input sample at which a unique FIR interpolation filter is computed, specified as a positive integer in the range [2 65535].
Example: 20
Example: 5
Dependencies
This property applies only when you set the InterpolationMethod property to
'FIR'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Bandwidth
— Normalized input bandwidth
1
(default) | real scalar in the range (0 1
]
Normalized input bandwidth at which to constrain the interpolated output samples,
specified as a real scalar in the range (0 1
]. A value of
1
equals the Nyquist frequency, or half the sampling frequency,
Fs. Use this property to take advantage of the bandlimited
frequency content of the input. For example, if the input signal does not have frequency
content above Fs/4, you can specify a value of
0.5
.
Example: 0.5
Example: 0.8
Dependencies
This property applies only when you set the InterpolationMethod property to
'FIR'
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| fi
InitialConditions
— Initial values in the memory
0
(default) | scalar | 1-by-N-by-D array | 1-by-N-by-(D+L) array
Initial values in the memory of the object, specified as a scalar or an array. The dimensions of this property can vary depending on whether you want fixed or time-varying initial conditions. The object treats each of the N input columns as a frame containing M sequential time samples from an independent channel.
For an M-by-N input matrix,
U, you can set the InitialConditions
property
as follows :
To specify fixed initial conditions, specify
InitialConditions
as a scalar value. The object initializes every sample of every channel in memory using the value you specify.The dimensions you specify for time-varying initial conditions depend on the value of the InterpolationMethod property.
When
InterpolationMethod
is set to'Linear'
, specifyInitialConditions
as a1
-by-N-by-D, where D is the value of the MaximumDelay property.When
InterpolationMethod
is set to'FIR'
or'Farrow'
, specifyInitialConditions
as a 1-by-N-by-(D+L) array, where D is the value of theMaximumDelay
property. For FIR interpolation, L is the value of theFilterHalfLength
property. For Farrow interpolation, L equals thefloor
of half the value of theFilterLength
property:floor(FilterLength/2)
.
Example: 1
Example: randn(1,3,104)
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
MaximumDelay
— Maximum delay
100
(default) | integer in the range [0 65535
]
Maximum delay that the object can produce for any sample, specified as an integer in
the range [0 65535
]. The object clips input delay values greater than
MaximumDelay
to that maximum value.
Example: 100
Example: 10
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
FIRSmallDelayAction
— Action to take for small input delay values when object uses FIR interpolation method
'Clip to the minimum value necessary for centered
kernel'
(default) | 'Switch to linear interpolation if kernel cannot be
centered'
Action taken for small input delay values when the object uses the FIR interpolation method.
Dependencies
This property applies only when you set the InterpolationMethod
property to 'FIR'
.
FarrowSmallDelayAction
— Action to take for small input delay values when object uses Farrow interpolation method
'Clip to the minimum value necessary for centered
kernel'
(default) | 'Use off-centered kernel'
Action taken for small input delay values when the object uses the farrow interpolation method.
Dependencies
This property applies only when you set the InterpolationMethod
property to 'Farrow'
.
RoundingMethod
— Rounding method for fixed-point operations
'Zero'
(default) | 'Ceiling'
| 'Convergent'
| 'Floor'
| 'Nearest'
| 'Round'
| 'Simplest'
Rounding mode for fixed-point operations, specified as one of the following:
'Zero'
'Ceiling'
'Convergent'
'Floor'
'Nearest'
'Round'
'Simplest'
For more details, see rounding mode.
OverflowAction
— Overflow action for fixed-point operations
'Wrap'
(default) | 'Saturate'
Overflow action for fixed-point operations, specified as one of the following:
'Wrap'
–– The object wraps the result of its fixed-point operations.'Saturate'
–– The object saturates the result of its fixed-point operations.
For more details on overflow actions, see overflow mode for fixed-point operations.
CoefficientsDataType
— Data type of the coefficients
'Same word length as input'
(default) | 'Custom'
Data type of the coefficients in this object, specified as one of the following:
'Same word length as input'
–– The object specifies the coefficients word length to be the same as that of the input. The fraction length is computed to get the best possible precision.'Custom'
–– The coefficients data type is specified as a custom numeric type through the CustomCoefficientsDataType property.
For more information on the coefficients data type this object uses, see the Fixed Point section.
CustomCoefficientsDataType
— Coefficient word and fraction lengths
numerictype([],32)
(default) | numerictype
Coefficient word and fraction lengths, specified as an autosigned numeric type with a word length of 32.
Dependencies
This property applies only when you set CoefficientsDataType to
'Custom'
.
ProductPolynomialValueDataType
— Data type of the product polynomial value
'Same as first input'
(default) | 'Custom'
Data type of the product polynomial value, specified as one of the following:
'Same as first input'
–– The object specifies the product polynomial value data type to be the same as that of the data input.'Custom'
–– The product polynomial value data type is specified as a custom numeric type through the CustomProductPolynomialValueDataType property.
For more information on the product polynomial value data type this object uses, see the Fixed Point section.
Dependencies
This property applies when you set InterpolationMethod to
'Farrow'
.
CustomProductPolynomialValueDataType
— Word and fraction lengths of product polynomial value
numerictype([],32,10)
(default)
Word and fraction lengths of the product polynomial value, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Example: numerictype([],30,5)
Dependencies
This property applies only when you set InterpolationMethod to 'Farrow'
and ProductPolynomialValueDataType to
'Custom'
.
AccumulatorPolynomialValueDataType
— Data type of the accumulator polynomial value
'Same as first input'
(default) | 'Custom'
Data type of the accumulator polynomial value, specified as one of the following:
'Same as first input'
–– The object specifies the accumulator polynomial value data type to be the same as that of the data input.'Custom'
–– The accumulator polynomial value data type is specified as a custom numeric type through the CustomAccumulatorPolynomialValueDataType property.
For more information on the accumulator polynomial value data type that this object uses, see the Fixed Point section.
Dependencies
This property applies when you set InterpolationMethod to
'Farrow'
.
CustomAccumulatorPolynomialValueDataType
— Word and fraction lengths of accumulator polynomial value
numerictype([],32,10)
(default)
Word and fraction lengths of the accumulator polynomial value, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Example: numerictype([],30,5)
Dependencies
This property applies only when you set InterpolationMethod to 'Farrow'
and AccumulatorPolynomialValueDataType to
'Custom'
.
MultiplicandPolynomialValueDataType
— Data type of multiplicand polynomial value
'Same as first input'
(default) | 'Custom'
Data type of multiplicand polynomial value, specified as one of the following:
'Same as first input'
–– The object specifies the multiplicand polynomial value data type to be the same as that of the data input.'Custom'
–– The multiplicand polynomial value data type is specified as a custom numeric type through the CustomMultiplicandPolynomialValueDataType property.
For more information on the multiplicand polynomial value data type that this object uses, see the Fixed Point section.
Dependencies
This property applies when you set InterpolationMethod to
'Farrow'
.
CustomMultiplicandPolynomialValueDataType
— Word and fraction lengths of multiplicand polynomial value
numerictype([],32,10)
(default) | numerictype
Word and fraction lengths of the multiplicand polynomial value, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Dependencies
This property applies only when you set InterpolationMethod to 'Farrow'
and MultiplicandPolynomialValueDataType to
'Custom'
.
ProductDataType
— Data type of product output
'Same as first input'
(default) | 'Custom'
Data type of the product output in this object, specified as one of the following:
'Same as first input'
–– The object specifies the product output data type to be the same as that of the data input.'Custom'
–– The product output data type is specified as a custom numeric type through the CustomProductDataType property.
For more information on the product output data type, see Multiplication Data Types and the Fixed Point section.
CustomProductDataType
— Word and fraction lengths of product data type
numerictype([],32,10)
(default) | numerictype
Word and fraction lengths of the product data type, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Example: numerictype([],30,5)
Dependencies
This property applies only when you set ProductDataType to
'Custom'
.
AccumulatorDataType
— Data type of accumulation operation
'Same as product'
(default) | 'Same as first input'
| 'Custom'
Data type of an accumulation operation in this object, specified as one of the following:
'Same as product'
–– The object specifies the accumulator data type to be the same as that of the product output data type.'Same as first input'
–– The object specifies the accumulator data type to be the same as that of the data input.'Custom'
–– The accumulator data type is specified as a custom numeric type through the CustomAccumulatorDataType property.
For more information on the accumulator data type this object uses, see the Fixed Point.
CustomAccumulatorDataType
— Word and fraction lengths of accumulator data type
numerictype([],32,10)
(default) | numerictype
Word and fraction lengths of the accumulator data type, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Example: numerictype([],30,5)
Dependencies
This property applies only when you set AccumulatorDataType to
'Custom'
.
OutputDataType
— Data type of object output
'Same as accumulator'
(default) | 'Same as first input'
| 'Custom'
Data type of the object output, specified as one of the following:
'Same as accumulator'
–– The object specifies the output data type to be the same as that of the accumulator output data type.'Same as first input'
–– The object specifies the output data type to be the same as that of the data input.'Custom'
–– The output data type is specified as a custom numeric type through the CustomOutputDataType property.
For more information on the output data type this object uses, see the Fixed Point section.
CustomOutputDataType
— Word and fraction lengths of output data type
numerictype([],32,10)
(default) | numerictype
Word and fraction lengths of the output data type, specified as an autosigned numeric type with a word length of 32 and a fraction length of 10.
Example: numerictype([],30,5)
Dependencies
This property applies only when you set OutputDataType to 'Custom'
.
Usage
Syntax
Description
Input Arguments
input
— Data input
vector | matrix
Data input, specified as a vector or matrix. The data input must have the same data type as the delay input.
This object supports variable-size input signal, that is, you can change the input frame size (number of rows) N even after calling the algorithm. However, the number of channels L must remain constant. For an example, see Variable-Size Signal Support for Input and Delay Signals.
Example: [1 2 3 4;5 1 4 2;2 6 2 3;1 2 3 2;3 4 5 6;1 2 3 1]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
d
— Delay input in samples
scalar | vector | matrix | N-D array
Delay input in samples, specified as a scalar, vector, matrix, or an N-D array. The delay can be an integer or a fractional value. When the delay input is a fractional value, the object interpolates the signal to obtain new samples at noninteger sampling intervals. The delay input must have the same data type as the data input.
To determine the range of this delay, call the info
function on the object vfd
. If you specify a delay value that is less
than the minimum acceptable value, the object performs the action you choose in the
FIRSmallDelayAction
,
FarrowSmallDelayAction
properties. If you set the
InterpolationMethod
to 'Linear'
, the minimum
acceptable value is 0.
If you specify a delay value that is greater than the maximum acceptable value, the object clips the delay value to the maximum value.
This object supports variable-size delay signal, that is, you can change the first dimension of the delay signal even after calling the algorithm. However, the number of channels L and the number of taps per channel P must remain constant. For an example, see Variable-Size Signal Support for Input and Delay Signals.
The table shows the effect of the dimension of the delay input on the data input.
Data Input | Delay Input | Output | Effect of Delay Input on Data Input |
---|---|---|---|
N-by-1 (one channel with frame size equal to N) | scalar | N-by-1 | One delay value applied to the input channel |
N-by-1 (one channel with frame size equal to N) | N-by-1 | N-by-1 | Delay value varies within the frame from sample to sample |
N-by-1 (one channel with frame size equal to N) | 1-by-P | N-by-P | P taps per channel. Each column in the output is a delayed version of the input. The delay value is specified by the corresponding element in the delay input vector. |
N-by-1 (one channel with frame size equal to N) | N-by-P | N-by-P | P taps per channel. In addition, delay varies within each frame from sample to sample. |
N-by-L (L channels with frame size equal to N) | scalar | N-by-L | One delay value applied to all input channels |
N-by-L (L channels with frame size equal to N) | 1-by-L | N-by-L | Unique delay value for each input channel |
N-by-L (L channels with frame size equal to N) | N-by-1 | N-by-L | Delay value varies within the frame from sample to sample. Same set of delay values for all channels. |
N-by-L (L channels with frame size equal to N) | N-by-L | N-by-L | Delay value varies within the frame from sample to sample. Different delay values for each input channel. |
N-by-L (L channels with frame size equal to N) | 1-by-1-by-P | N-by-L-by-P | L channels. P taps per channel. Same delay for all channels. |
N-by-L (L channels with frame size equal to N) | 1-by-L-by-P | N-by-L-by-P | L channels. P taps per channel. Delay varies across channels. |
N-by-L (L channels with frame size equal to N) | N-by-1-by-P | N-by-L-by-P | L channels. P taps per channel. Delay varies within the frame from sample to sample. Same set of delay values for each channel. |
N-by-L (L channels with frame size equal to N) | N-by-L-by-P | N-by-L-by-P | L channels. P taps per channel. Delay varies within the frame from sample to sample. Different set of delay values for each channel. |
Example: [2 3 4 5]
Example: [2.5]
Example: [5.6]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Output Arguments
vfdOut
— Delayed output
vector | matrix
Delayed output, returned as a vector or matrix. The size, data type, and complexity of the output match the size, data type, and complexity of the data input.
The table shows how the data input and delay input dimensions affect the output dimensions:
Data Input | Delay Input | Output | Effect of Delay Input on Data Input |
---|---|---|---|
N-by-1 (one channel with frame size equal to N) | scalar | N-by-1 | One delay value applied to the input channel |
N-by-1 (one channel with frame size equal to N) | N-by-1 | N-by-1 | Delay value varies within the frame from sample to sample |
N-by-1 (one channel with frame size equal to N) | 1-by-P | N-by-P | P taps per channel. Each column in the output is a delayed version of the input. The delay value is specified by the corresponding element in the delay input vector. |
N-by-1 (one channel with frame size equal to N) | N-by-P | N-by-P | P taps per channel. In addition, delay varies within each frame from sample to sample. |
N-by-L (L channels with frame size equal to N) | scalar | N-by-L | One delay value applied to all input channels |
N-by-L (L channels with frame size equal to N) | 1-by-L | N-by-L | Unique delay value for each input channel |
N-by-L (L channels with frame size equal to N) | N-by-1 | N-by-L | Delay value varies within the frame from sample to sample. Same set of delay values for all channels. |
N-by-L (L channels with frame size equal to N) | N-by-L | N-by-L | Delay value varies within the frame from sample to sample. Different delay values for each input channel. |
N-by-L (L channels with frame size equal to N) | 1-by-1-by-P | N-by-L-by-P | L channels. P taps per channel. Same tap for all channels. |
N-by-L (L channels with frame size equal to N) | 1-by-L-by-P | N-by-L-by-P | L channels. P taps per channel. Taps vary across channels. |
N-by-L (L channels with frame size equal to N) | N-by-1-by-P | N-by-L-by-P | L channels. P taps per channel. Delay varies within the frame from sample to sample. Same set of delay values for each channel. |
N-by-L (L channels with frame size equal to N) | N-by-L-by-P | N-by-L-by-P | L channels. P taps per channel. Delay varies within the frame from sample to sample. Different set of delay values for each channel. |
Example: [0 0 0 0;0 0 0 0;1 0 0 0;5 2 0 0;2 1 3 0;1 6 4 4]
Example: [0 0 0 0;0 0 0 0;0.5 1.0 1.5 2.0;3 1.5 3.5 3.0;3.5 3.5 3.0 2.5;1.5 4.0 2.5 2.5]
Example: [0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0;0.4 0.8 1.2 1.6]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Specific to dsp.VariableFractionalDelay
info | Characteristic information about valid delay range |
generatehdl | Generate HDL code for quantized DSP filter (requires Filter Design HDL Coder) |
Examples
Signal Delay using Variable Fractional Delay
Delay a signal by a varying fractional number of sample periods using the dsp.VariableFractionalDelay
object. The object uses the 'Linear'
interpolation method.
Specify the input signal using the dsp.SignalSource
object.
sr = dsp.SignalSource; vfd = dsp.VariableFractionalDelay(InterpolationMethod="Linear",... MaximumDelay=20)
vfd = dsp.VariableFractionalDelay with properties: InterpolationMethod: 'Linear' InitialConditions: 0 MaximumDelay: 20 Use get to show all properties
sink = dsp.SignalSink;
Determine the range of the delay values that the variable fractional delay object accepts by calling the info
function.
info(vfd)
ans = struct with fields:
ValidDelayRange: '[0, 20]'
Specify the delay values to the object within this range. In this example, the delay value varies from 0.1 to 1 sample.
for ii = 1:10 delayedsig = vfd(sr(), ii/10); sink(delayedsig); end sigd = sink.Buffer;
The output sigd
corresponds to the values of the delayed signal that are sampled at fixed-time intervals. To plot the time instants at which the amplitudes of signal samples are constant, treat the signals as the sampling instants.
stem(sr.Signal,1:10,'b') hold on; stem(sigd.',1:10,'r'); legend('Original signal', ... 'Variable fractional delayed signal', ... 'Location','best')
Signal Delay Using Multitap Fractional Delay
Delay the input signal using the dsp.VariableFractionalDelay
object. Each delay value is unique and can vary from sample to sample within a frame, and can vary across channels. You can compute multiple delayed versions of the same input signal concurrently by passing a delay input with the appropriate dimension.
Consider the input to be a random signal with one channel and a frame size of 10. Apply a delay of 4.8 and 8.2 samples concurrently.
vfd = dsp.VariableFractionalDelay
vfd = dsp.VariableFractionalDelay with properties: InterpolationMethod: 'Linear' InitialConditions: 0 MaximumDelay: 100 Use get to show all properties
in = randn(10,1)
in = 10×1
0.5377
1.8339
-2.2588
0.8622
0.3188
-1.3077
-0.4336
0.3426
3.5784
2.7694
delayVec = [4.8 8.2]; outcase1 = vfd(in,delayVec)
outcase1 = 10×2
0 0
0 0
0 0
0 0
0.1075 0
0.7969 0
1.0153 0
-1.6346 0
0.7535 0.4301
-0.0065 1.5746
Each channel in the output is delayed by 4.8 and 8.2 samples, respectively. The object uses the 'Linear' interpolation method to compute the delayed value. For more details, see 'Algorithms' in the dsp.VariableFractionalDelay object page
.
For the same delay vector, if the input has 2 channels, each element of the delay vector is applied on the corresponding channel in the input.
release(vfd); in = randn(10,2)
in = 10×2
-1.3499 0.6715
3.0349 -1.2075
0.7254 0.7172
-0.0631 1.6302
0.7147 0.4889
-0.2050 1.0347
-0.1241 0.7269
1.4897 -0.3034
1.4090 0.2939
1.4172 -0.7873
outcase2 = vfd(in,delayVec)
outcase2 = 10×2
0 0
0 0
0 0
0 0
-0.2700 0
-0.4729 0
2.5730 0
0.5677 0
0.0925 0.5372
0.5308 -0.8317
To compute multiple delayed versions of the two-dimensional input signal, pass the delay vector as a three-dimensional array. The third dimension contains the taps or delays to apply on the signal. If you pass a non-singleton third dimension (1-by-1-by-P), where P represents the number of taps, the same tap is applied across all the channels. Pass the delays [4.8 8.2] in the third dimension.
clear delayVec; delayVec(1,1,1) = 4.8; delayVec(1,1,2) = 8.2; whos delayVec
Name Size Bytes Class Attributes delayVec 1x1x2 16 double
delayVec
is a 1-by-1-by-2 array. Pass the two-dimensional input to the dsp.VariableFractionalDelay
object with this delay vector.
release(vfd); outcase3 = vfd(in,delayVec)
outcase3 = outcase3(:,:,1) = 0 0 0 0 0 0 0 0 -0.2700 0.1343 -0.4729 0.2957 2.5730 -0.8225 0.5677 0.8998 0.0925 1.4020 0.5308 0.5981 outcase3(:,:,2) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.0799 0.5372 2.1580 -0.8317
whos outcase3
Name Size Bytes Class Attributes outcase3 10x2x2 320 double
outcase3(:,:,1)
represents the input signal delayed by 4.8 samples. outcase3(:,:,2)
represents the input signal delayed by 8.2 samples. The same delay is applied across all the channels.
In addition, if you pass a non-singleton second dimension (1-by-L-by-P), where L is the number of input channels, taps vary across channels. Apply the delay vectors [2.3 3.5] and [4.4 5.6] to compute the two delayed versions of the input signal.
clear delayVec; delayVec(1,1,1) = 2.3; delayVec(1,2,1) = 3.5; delayVec(1,1,2) = 4.4; delayVec(1,2,2) = 5.6; whos delayVec
Name Size Bytes Class Attributes delayVec 1x2x2 32 double
release(vfd); outcase4 = vfd(in,delayVec)
outcase4 = outcase4(:,:,1) = 0 0 0 0 -0.9449 0 1.7195 0.3357 1.4183 -0.2680 0.1735 -0.2451 0.4814 1.1737 0.0709 1.0596 -0.1484 0.7618 1.0055 0.8808 outcase4(:,:,2) = 0 0 0 0 0 0 0 0 -0.8099 0 1.2810 0.2686 1.6492 -0.0801 0.2523 -0.4376 0.4036 1.0824 0.1629 1.1737
whos outcase4
Name Size Bytes Class Attributes outcase4 10x2x2 320 double
outcase4(:,:,1)
contains the input signal delayed by the vector [2.3 3.5]. outcase4(:,:,2)
contains the input signal delayed by the vector [4.4 5.6].
To vary the delay within a frame from sample to sample, the first dimension of the delay vector (N-by-1-by-P or N-by-L-by-P) must equal the frame size of the input (N-by-L). Pass a delay vector of size 10-by-1-by-2.
clear delayVec; delayVec(:,1,1) = 3.1:0.1:4; delayVec(:,1,2) = 0.1:0.1:1; whos delayVec
Name Size Bytes Class Attributes delayVec 10x1x2 160 double
release(vfd); outcase5 = vfd(in,delayVec)
outcase5 = outcase5(:,:,1) = 0 0 0 0 0 0 -0.8099 0.4029 0.8425 -0.2680 2.1111 -0.4376 0.4889 0.9911 0.0925 1.4020 0.6228 0.5435 -0.2050 1.0347 outcase5(:,:,2) = -1.2149 0.6043 2.1580 -0.8317 1.4183 0.1398 0.2523 1.2650 0.3258 1.0596 0.3469 0.7072 -0.1807 0.9424 0.1986 0.5208 1.4816 -0.2437 1.4090 0.2939
Delay varies across each element in a channel. Same set of delay values apply across all channels. delayVec(:,1,1)
applies to the first delayed signal and delayVec(:,1,2)
applies to the second delayed signal.
Variable-Size Signal Support for Input and Delay Signals
dsp.VariableFractionalDelay
System object supports variable-size input and delay signals. That is, you can change the dimension of the input signal and the delay signal even after calling the algorithm. You can change the dimensions of one or both the signals simultaneously. Together, they must make sure that the number of output channels (number of columns) remains constant.
Variable-Size Support for Input Signal
The number of samples in each frame of the input signal can change. However, the number of input channels must remain constant.
Create a dsp.VariableFractionalDelay
object. Pass an input signal of size [256 1] and a delay of 1.4 to the object algorithm. In subsequent calls to the algorithm, change the input frame size to 128, 512, and 64, respectively
vfd = dsp.VariableFractionalDelay; vfd(randn(256,1),1.4); vfd(randn(128,1),1.4); vfd(randn(512,1),1.4); vfd(randn(64,1),1.4);
The output frame size (number of rows) changes according to the input frame size. The number of output channels in each of these cases is 1.
To change the number of input channels, release the object.
release(vfd);
Call the algorithm with a two-channel input and vary the input frame size in subsequent calls.
vfd(randn(256,2),1.4); vfd(randn(128,2),1.4);
Variable-Size Support for Delay Signal
In addition to the input, the delay signal can also vary. That is, you can change one or both of the dimensions of the delay signal after calling the algorithm. However, the object must make sure that the resulting number of output channels remains constant. The delay signal can be a scalar, vector, matrix, or an N-D array.
release(vfd); vfd(randn(512,2),randn(512,2)); vfd(randn(128,2),[1.4 1.7]); vfd(randn(256,2),randn(256,1)); vfd(randn(128,2),1.4);
In each of these cases, the number of output channels is 2. To apply different delays on the input signal, release the object.
release(vfd); vfd(randn(256,1),randn(256,7)); vfd(randn(512,1),randn(512,7)); vfd(randn(100,1),randn(100,7)); vfd(randn(100,1),randn(1,7));
The output in each of these cases is [256 7], [512 7], [100 7], and [100 7], respectively.
More About
Fixed Point
The diagrams in the following sections show the data types used within the
dsp.VariableFractionalDelay
object for fixed-point signals.
Although you can specify most of these data types, the following data types are computed internally by the object and cannot be directly specified on the object interface.
Data Type | Word Length | Fraction Length |
---|---|---|
vf data type | Same word length as the coefficients | Same as the word length |
HoldInteger data type | Same word length as the input delay value | 0 bits |
Integer data type | 32 bits | 0 bits |
Note
When the input is fixed point, all internal data types are signed fixed point.
The following diagram shows the fixed-point data types used by the Linear interpolation mode of the variable fractional delay algorithm.
The following diagram illustrates how the variable fractional delay object selects the arm of the polyphase filter structure that most closely matches the fractional delay value (vf).
The following diagram shows the fixed-point data types used by the variable fractional delay algorithm in the FIR interpolation mode.
You can set the coefficient, product output, accumulator, and output data types in the object. This diagram shows that input data is stored in the input buffer with the same data type and scaling as the input. The object stores filtered data and any initial conditions in the output buffer using the output data type and scaling that you set.
When at least one of the inputs to the multiplier is real, the output of the multiplier is in the product output data type. When both inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication, see Multiplication Data Types.
The following diagram shows the fixed-point data types used by the Farrow interpolation mode when:
Farrow filter length is set to
4
Farrow small delay action is set to
'Clip to the minimum value necessary for centered kernel'
The following diagram shows the fixed-point data types used by the Farrow interpolation mode when:
Farrow filter length is set to
4
Farrow small delay action is set to
'Use off-centered kernel'
Diff
is computed from the integer part of the delay value
(vi) and the farrow filter length
(N) according to the following equation:
The following diagram shows the fixed-point data types used by the FIR direct form filter.
Algorithms
When you specify a fractional delay value, the algorithm uses a linear, FIR, or Farrow interpolation method to interpolate signal values at noninteger sample intervals.
Linear Interpolation Mode
For noninteger delays, at each sample time, the linear interpolation method uses the two samples in memory nearest to the specified delay to compute a value for the sample at that time.
For a vector data input, the output vector, y, is computed using the following relation:
vi = floor(v) vf = v-vi y(i) = U(i-vi-1)*vf + U(i-vi)*(1-vf)
where,
i –– Index of the current sample
v –– Fractional delay
vi –– Integer part of the delay
vf –– Fractional part of the delay
U –– Input data vector
y –– Output data vector
U(i-vi), U(i-vi-1) –– Two samples in memory nearest to the specified delay
i-vi –– Distance, in samples, between the current index and the nearest point in the interpolation line.
The variable fractional delay stores the Dmax+1 most recent samples received at the input for each channel, where Dmax is the maximum delay specified. U represents the stored samples.
FIR Interpolation Mode
In the FIR interpolation mode, the variable fractional delay stores the Dmax+P+1 most recent samples received at the input for each channel, where P is the specified interpolation filter half-length.
In this mode, the object provides a discrete set of fractional delays:
If v is less than P – 1, the behavior depends on the FIR small delay value action setting. You can specify the object's behavior when the input delay value is too small to center the kernel (less than P-1), by setting the FIR small delay value action setting:
Clip to the minimum value necessary for centered kernel
–– The FIR interpolation method remains in use. The small input delay values are clipped to the smallest value necessary to center the kernel.Switch to linear interpolation if kernel cannot be centered
–– Fractional delays are computed using linear interpolation when the input delay value is less than P-1.
In the FIR interpolation mode, the algorithm implements a polyphase structure to compute a value for each sample at the specified delay. Each arm of the structure corresponds to a different delay value. The output computed for each sample corresponds to the output of the arm with a delay value nearest to the specified input delay. Therefore, only a discrete set of delays is actually possible. The number of coefficients in each of the L filter arms of the polyphase structure is 2P. In most cases, using values of P between 4 and 6 provides you with reasonably accurate interpolation values.
The designMultirateFIR
function designs the FIR interpolation
filter.
For example, when you set the following values:
Interpolation filter half-length (P) to 4
Interpolation points per input sample to 10
Normalized input bandwidth to 1
Stopband attenuation to 80 dB
The filter coefficients are given by:
b = designMultirateFIR(10,1,4,80);
Increasing the filter half length (P) increases the accuracy of the interpolation, but also increases the number of computations performed per input sample. The amount of memory needed to store the filter coefficients increases too. Increasing the interpolation points per sample (L) increases the number of representable discrete delay points, but also increases the simulation's memory requirements. The computational load per sample is not affected.
The normalized input bandwidth from 0 to 1 allows you to take advantage of the
bandlimited frequency content of the input. For example, if you know that the input signal
does not have frequency content above Fs/4, you can specify
0.5
normalized bandwidth to constrain the frequency content of the
output to that range.
Note
You can consider each of the L interpolation filters to correspond to one output phase of an upsample-by-L FIR filter. Therefore, the normalized input value improves the stopband in critical regions and relaxes the stopband requirements in frequency regions without signal energy.
Farrow Interpolation Mode
In Farrow interpolation mode, the algorithm uses the LaGrange method to interpolate values.
The order of the polynomial used for the interpolation is based on the number of data points used in the Lagrange interpolation. This value is specified in the FilterLength property.
To specify the behavior when the input delay value is too small to center the kernel (less than – 1), use the Farrow small delay action setting.
Clip to the minimum value necessary for centered kernel
–– The algorithm clips small input delay values to the smallest value necessary to keep the kernel centered. This option yields more accurate interpolation values.Use off-centered kernel
–– The fractional delays are computed using a Farrow filter with an off-centered kernel. The results for input delay values less than – 1 are less accurate than the results achieved by keeping the kernel centered.When the length of the farrow filter is 2, the filter performs linear interpolation.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
This object supports HDL code generation with the Filter Design HDL Coder™ product. For workflows and limitations, see Generate HDL Code for Filter System Objects (Filter Design HDL Coder).
Version History
Introduced in R2012a
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)