interpolate signal using cascaded integrator-凯发k8网页登录
interpolate signal using cascaded integrator-comb filter
description
the dsp.cicinterpolator
system object™ interpolates an input signal using a cascaded integrator-comb (cic)
interpolation filter. the cic interpolation filter structure consists of n
sections of cascaded comb filters, followed by a rate change by a factor of
r, followed by n sections of cascaded integrators. for
details, see algorithms. the numsections property specifies n, the number of sections in
the cic filter. the interpolationfactor property
specifies r, the interpolation factor. the
function returns the word lengths and fraction lengths of the fixed-point sections and the
output for the dsp.cicinterpolator
system object. you can also generate hdl code for this system object using the
function.
note
this object requires a fixed-point designer™ license.
to interpolate a signal using a cic filter:
create the
dsp.cicinterpolator
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
syntax
description
creates a
cic interpolation system object that applies a cic interpolation filter to the input signal.cicinterp
= dsp.cicinterpolator
creates a cic interpolation object with the cicinterp
= dsp.cicinterpolator(r
,m
,n
)interpolationfactor
property set to r
, the differentialdelay
property set to m
, and the numsections
property
set to n
.
creates a cic interpolation object with each specified property set to the specified
value. enclose each property name in single quotes. you can use this syntax with any
previous input argument combinations.cicinterp
= dsp.cicinterpolator(name,value
)
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 function unlocks them.
if a property is tunable, you can change its value at any time.
for more information on changing property values, see .
interpolationfactor
— interpolation factor
2
(default) | positive integer
factor by which the input signal is interpolated, specified as a positive integer.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
differentialdelay
— differential delay of filter comb sections
1
(default) | positive integer
differential delay value used in each of the comb sections of the filter, specified
as a positive integer. for details, see algorithms. if the
differential delay is of built-in integer class data type, the interpolation factor must
be the same integer data type or double
. for example, if the
differential delay is an int8
, then the interpolation factor must be
an int8
or double
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
numsections
— number of integrator and comb sections
2
(default) | positive integer
number of integrator and comb sections of the cic filter, specified as a positive integer. this number indicates the number of sections in either the comb part or the integrator part of the filter. the total number of sections in the cic filter is twice the number of sections given by this property.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
fixedpointdatatype
— fixed-point property designations
full precision
(default) | minimum section word lengths
| specify word lengths
| specify word and fraction lengths
fixed-point property designations, specified as one of the following:
full precision
– the word length and fraction length of the cic filter sections and the object output operate in full precision.minimum section word lengths
– specify the output word length through the outputwordlength property. the object determines the filter section data type and the output fraction length that give the best possible precision. for details, see andcicinterpout
argument.specify word lengths
– specify the word lengths of the cic filter sections and the object output through the sectionwordlengths and outputwordlength properties. the object determines the corresponding fraction lengths to give the best possible precision. for details, see and thecicinterpout
argument.specify word and fraction lengths
– specify the word length and fraction length of the cic filter sections and the object output through the sectionwordlengths, sectionfractionlengths, outputwordlength, and outputfractionlength properties.
sectionwordlengths
— fixed-point word lengths for each filter section
[16 16 16 16]
(default) | scalar | vector
fixed-point word lengths to use for each filter section, specified as a scalar or a
row vector of integers. the word length must be greater than or equal to 2. if you
specify a scalar, the value applies to all the sections of the filter. if you specify a
vector, the vector must be of length 2 × numsections
.
example: 32
example: [32 32 32 32]
dependencies
this property applies when you set the fixedpointdatatype
property to 'specify word lengths'
or 'specify word and
fraction lengths'
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
sectionfractionlengths
— fixed-point fraction lengths for each filter section
0
(default) | scalar | vector
fixed-point fraction lengths to use for each filter section, specified as a scalar
or a row vector of integers. the fraction length can be negative, 0, or positive. if you
specify a scalar, the value applies to all the sections of the filter. if you specify a
vector, the vector must be of length 2 × numsections
.
example: -2
example: [-2 0 5 8]
dependencies
this property applies when you set the fixedpointdatatype
property to 'specify word and fraction lengths'
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
outputwordlength
— fixed-point word length for filter output
32
(default) | scalar integer
fixed-point word length to use for the filter output, specified as a scalar integer greater than or equal to 2.
dependencies
this property applies when you set the fixedpointdatatype
property to one of 'minimum section word lengths'
,
'specify word lengths'
, or 'specify word and fraction
lengths'
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
outputfractionlength
— fixed-point fraction length for filter output
0
(default) | scalar integer
fixed-point fraction length to use for the filter output, specified as a scalar integer.
dependencies
this property applies when you set the fixedpointdatatype
property to 'specify word and fraction lengths'
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
usage
description
interpolates
the input using a cic interpolator.cicinterpout
= cicinterp(input)
input arguments
input
— data input
vector | matrix
data input, specified as a vector or matrix. if the input is of single or double data type, property settings related to the fixed-point data types are ignored.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
complex number support: yes
output arguments
cicinterpout
— cic interpolator output
vector | matrix
interpolated output, returned as a vector or a matrix. the output frame size
equals (interpolationfactor) × input frame size. the
complexity of the output data matches that of the input data. if the input is
single
or double
, the output data type matches
the input data type.
if the input is of built-in integer data type or of fixed-point data type, the output word length and fraction length depend on the fixed-point data type setting you choose through the fixedpointdatatype property.
full precision
when the fixedpointdatatype
property is set to
'full precision'
, the following relationship applies:
where,
wloutput –– word length of the output data.
floutput –– fraction length of the output data.
wlinput –– word length of the input data.
flinput –– fraction length of the input data.
numsect –– number of sections in the cic filter specified through the numsections property.
wlinput and flinput are inherited from the data input you pass to the object algorithm. for built-in integer inputs, the fraction length is 0.
minimum section word lengths
when the fixedpointdatatype
property is set to
'minimum section word lengths'
, the output word length is the
value you specify in outputwordlength property. the output fraction
length, floutput is given by the following
equation:
specify word and fraction lengths
when the fixedpointdatatype
is set to 'specify word
and fraction lengths'
, the output word length and fraction length are the
values you specify in the outputwordlength and outputfractionlength properties.
specify word lengths
when the fixedpointdatatype
is set to 'specify word
lengths'
, the output word length is the value you specify in the
outputwordlength
property. the output fraction length,
floutput is given by the following
equation:
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.cicinterpolator
generate hdl code for quantized dsp filter (requires filter design hdl coder) | |
impulse response of discrete-time filter system object | |
frequency response of discrete-time filter system object | |
phase response of discrete-time filter system object (unwrapped) | |
visualize frequency response of dsp filters | |
gain of cic filter system object | |
get fixed-point word and fraction lengths | |
information about filter system object |
common to all system objects
run system object algorithm | |
release resources and allow changes to system object property values and input characteristics | |
reset internal states of system object |
for a list of filter analysis methods this object supports, type
dsp.cicinterpolator.helpfilteranalysis
in the matlab® command prompt. for the corresponding function reference pages, see .
examples
interpolate signal using cicinterpolator system object
create a dsp.cicinterpolator
system object™ with interpolationfactor
set to 2. interpolate a fixed-point signal by a factor of 2 from 22.05 khz to 44.1 khz.
cicint = dsp.cicinterpolator(2)
cicint = dsp.cicinterpolator with properties: interpolationfactor: 2 differentialdelay: 1 numsections: 2 fixedpointdatatype: 'full precision'
create a object with samplerate
set to 22.05 khz, samplesperframe
set to 32, and outputdatatype
set to 'custom'
. to generate a fixed-point signal, set the customoutputdatatype
property to a numerictype
object. for the purpose of this example, set the value to numerictype([],16)
. the fraction length is computed based on the values of the generated sinusoidal signal to give the best possible precision.
to generate a fixed-point signal, set the method
property of the dsp.sinewave
object to 'table lookup'
. this method of generating the sinusoidal signal requires that the period of every sinusoid in the output be evenly divisible by the sample period. that is, must be an integer value for every channel i = 1, 2, ..., n. the value of equals , the variable is the frequency of the sinusoidal signal, and is the sample rate of the signal. in other words, the ratio must be an integer. for more details, see the section on the dsp.sinewave
object page.
in this example, is set to 22050 hz and is set to 1050 hz.
fs = 22.05e3; sine = dsp.sinewave('frequency',1050,... 'samplerate',fs,... 'samplesperframe',32,... 'method','table lookup',... 'outputdatatype','custom')
sine = dsp.sinewave with properties: amplitude: 1 frequency: 1050 phaseoffset: 0 complexoutput: false method: 'table lookup' tableoptimization: 'speed' samplesperframe: 32 samplerate: 22050 outputdatatype: 'custom' show all properties
in each loop of the iteration, stream in a frame of the fixed-point sinusoidal signal sampled at 22.05 khz. interpolate the streamed signal by a factor of 2. the interpolated output has 64 samples per frame.
for i = 1:16 x = sine(); y = cicint(x); end
the output of the cic interpolation filter is amplified by a specific gain value. you can determine this value using the function. this gain equals the gain of the stage of the cic interpolation filter and equals , where is the interpolation factor, is the differential delay, and is the number of sections of the cic interpolator.
gaincic = gain(cicint)
gaincic = 2
to adjust this amplified output and to match it to the amplitude of the original signal, divide the cic interpolated signal with the computed gain value.
compare the last frames of the original and the interpolated signals. while plotting, account for the output latency of 2 samples.
n = (0:63)'; stem(n(1:31)/fs,double(x(1:31)),'r','filled') hold on; i = cicint.interpolationfactor; stem(n(1:61)/(fs*i), ... double(y(4:end))/gaincic,'b') xlabel('time (sec)') ylabel('signal amplitude') legend('original signal',... 'interpolated signal',... 'location','north') hold off;
using the function in the 'long'
format, obtain the word lengths and fraction lengths of the fixed-point filter sections and the filter output.
info(cicint,'long')
ans = 'discrete-time fir multirate filter (real) ----------------------------------------- filter structure : cascaded integrator-comb interpolator interpolation factor : 2 differential delay : 1 number of sections : 2 stable : yes linear phase : yes (type 1) implementation cost number of multipliers : 0 number of adders : 4 number of states : 4 multiplications per input sample : 0 additions per input sample : 6 fixed-point info section word lengths : 17 17 17 17 section fraction lengths : 14 14 14 14 output word length : 17 output fraction length : 14 '
determine the section and output word lengths and fraction lengths
using the getfixedpointinfo
function, you can determine the word lengths and fraction lengths of the fixed-point sections and the output of the dsp.cicdecimator
and dsp.cicinterpolator
system objects. the data types of the filter sections and the output depend on the fixedpointdatatype
property of the filter system object™.
full precision
create a dsp.cicdecimator
object. the default value of the numsections
property is 2. this value indicates that there are two integrator and comb sections. the wls and fls vectors returned by the getfixedpointinfo
function contain five elements each. the first two elements represent the two integrator sections. the third and fourth elements represent the two comb sections. the last element represents the filter output.
cicd = dsp.cicdecimator
cicd = dsp.cicdecimator with properties: decimationfactor: 2 differentialdelay: 1 numsections: 2 fixedpointdatatype: 'full precision'
by default, the fixedpointdatatype
property of the object is set to 'full precision'
. calling the getfixedpointinfo
function on this object with the input numeric type, nt
, yields the following word length and fraction length vectors.
nt = numerictype(1,16,15)
nt = datatypemode: fixed-point: binary point scaling signedness: signed wordlength: 16 fractionlength: 15
[wls,fls] = getfixedpointinfo(cicd,nt) %#ok
wls = 1×5
18 18 18 18 18
fls = 1×5
15 15 15 15 15
for details on how the word lengths and fraction lengths are computed, see the description for output arguments.
if you lock the cicd
object by passing an input to its algorithm, you do not need to pass the nt
argument to the getfixedpointinfo
function.
input = int64(randn(8,1))
input = 8x1 int64 column vector
1
2
-2
1
0
-1
0
0
output = cicd(input)
output = 0 1 3 0 datatypemode: fixed-point: binary point scaling signedness: signed wordlength: 66 fractionlength: 0
[wls,fls] = getfixedpointinfo(cicd) %#ok
wls = 1×5
66 66 66 66 66
fls = 1×5
0 0 0 0 0
the output and section word lengths are the sum of input word length, 64 in this case, and the number of sections, 2. the output and section fraction lengths are 0 since the input is a built-in integer.
minimum section word lengths
release the object and change the fixedpointdatatype
property to 'minimum section word lengths'
. determine the section and output fixed-point information when the input is fixed-point data, fi(randn(8,2),1,24,15)
.
release(cicd);
cicd.fixedpointdatatype = 'minimum section word lengths'
cicd = dsp.cicdecimator with properties: decimationfactor: 2 differentialdelay: 1 numsections: 2 fixedpointdatatype: 'minimum section word lengths' outputwordlength: 32
inputf = fi(randn(8,2),1,24,15)
inputf = 3.5784 -0.1241 2.7694 1.4897 -1.3499 1.4090 3.0349 1.4172 0.7254 0.6715 -0.0630 -1.2075 0.7148 0.7172 -0.2050 1.6302 datatypemode: fixed-point: binary point scaling signedness: signed wordlength: 24 fractionlength: 15
[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf)) %#ok
wls = 1×5
26 26 26 26 32
fls = 1×5
15 15 15 15 21
specify word and fraction lengths
change the fixedpointdatatype
property to 'specify word and fraction lengths'
. determine the fixed-point information using the getfixedpointinfo
function.
cicd.fixedpointdatatype = 'specify word and fraction lengths'
cicd = dsp.cicdecimator with properties: decimationfactor: 2 differentialdelay: 1 numsections: 2 fixedpointdatatype: 'specify word and fraction lengths' sectionwordlengths: [16 16 16 16] sectionfractionlengths: 0 outputwordlength: 32 outputfractionlength: 0
[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf)) %#ok
wls = 1×5
16 16 16 16 32
fls = 1×5
0 0 0 0 0
the section and output word lengths and fraction lengths are assigned as per the respective fixed-point properties of the cicd
object. these values are not determined by the input numeric type. to confirm, call the getfixedpointinfo
function without passing the numerictype
input argument.
[wls, fls] = getfixedpointinfo(cicd) %#ok
wls = 1×5
16 16 16 16 32
fls = 1×5
0 0 0 0 0
specify word lengths
to specify the word lengths of the filter section and output, set the fixedpointdatatype
property to 'specify word lengths'
.
cicd.fixedpointdatatype = 'specify word lengths'
cicd = dsp.cicdecimator with properties: decimationfactor: 2 differentialdelay: 1 numsections: 2 fixedpointdatatype: 'specify word lengths' sectionwordlengths: [16 16 16 16] outputwordlength: 32
the getfixedpointinfo
function requires the input numeric type because that information is used to compute the section and word fraction lengths.
[wls, fls] = getfixedpointinfo(cicd,numerictype(inputf))
wls = 1×5
16 16 16 16 32
fls = 1×5
5 5 5 5 21
for more details on how the function computes the word and fraction lengths, see the description for output arguments.
more about
cic filter
cic filters are an optimized class of linear phase fir filters composed of a comb part and an integrator part.
the cic interpolation filter is conceptually given by an upsampler followed by a single rate cic filter, h(z), which is a lowpass anti-imaging filter. the cic interpolation filter increases the sample rate of an input signal by an integer factor using a cascaded integrator-comb (cic) filter.
in a more efficient implementation, the single rate cic filter h(z) is factorized this way:
where,
hc is the transfer function of the n sections of the cascaded comb filters, each with a width of rm.
hi is the transfer function of the integrator part of the filter containing n stages of integrators.
n is the number of sections. the number of sections in a cic filter is defined as the number of sections in either the comb part or the integrator part of the filter. this value does not represent the total number of sections throughout the entire filter.
r is the interpolation factor.
m is the differential delay.
in the overall multirate realization, the algorithm applies the noble identity for interpolation and moves the rate change factor, r, to follow after the n sections of the cascaded comb filters.
the transfer function of the resulting filter is given by the following equation:
for a block diagram that shows the multirate implementation, see algorithms.
fixed point
the fixed-point signal diagram shows the data types that the
dsp.cicinterpolator
object uses for fixed-point signals.
where,
secnt = numerictype(1,secwl,secfl)
outnt = numertictype(1,outwl,outfl)
secwl is the section word length you specify through the sectionwordlengths property.
secfl is the section fraction length you specify through the sectionfractionlengths property.
outwl is the output word length you specify through the outputwordlength property.
outfl is the output fraction length you specify through the outputfractionlength property.
the value of numsections
in this diagram is 2.
algorithms
cic interpolation filter
the cic interpolation filter in more about is realized as a cascade of n sections of comb filters followed by a rate change by a factor r, followed by n sections of cascaded integrators.
this diagram shows two sections of cascaded comb filters and two sections of cascaded integrators. the unit delay in the integrator portion of the cic filter can be located in either the feedforward or the feedback path. these two configurations yield identical filter frequency response. however, the numerical outputs from these two configurations are different due to the latency. this algorithm puts the unit delay in the feedforward path of the integrator since it is a preferred configuration for hdl implementation.
references
[1] hogenauer, e.b. "an economical class of digital filters for decimation and interpolation." ieee transactions on acoustics, speech and signal processing. volume 29, number 2, 1981, 155–162.
[2] meyer-baese, u. digital signal processing with field programmable gate arrays. new york: springer, 2001.
[3] harris, fredric j. multirate signal processing for communication systems. indianapolis, in: prentice hall ptr, 2004.
extended capabilities
c/c code generation
generate c and c code using matlab® coder™.
usage notes and limitations:
see (matlab coder).
hdl code generation
generate verilog and vhdl 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 (filter design hdl coder).
version history
introduced in r2012a
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 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
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)