decimate signal using cascaded integrator-凯发k8网页登录
decimate signal using cascaded integrator-comb (cic) filter
description
the dsp.cicdecimator
system object™ decimates an input signal using a cascaded integrator-comb (cic) decimation
filter. the cic decimation filter structure consists of n sections of
cascaded integrators, followed by a rate change by a factor of r, followed
by n sections of cascaded comb filters. for details, see algorithms. the numsections property specifies n, the number of sections in
the cic filter. the decimationfactor property
specifies r, the decimation factor. the
function returns the word lengths and fraction lengths of the fixed-point sections and the
output for the dsp.cicdecimator
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 decimate a signal using a cic filter:
create the
dsp.cicdecimator
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
decimation system object that applies a cic decimation filter to the input signal.cicdecim
= dsp.cicdecimator
creates a cic decimation object with the cicdecim
= dsp.cicdecimator(r
,m
,n
)decimationfactor
property
set to r
, the differentialdelay
property set to
m
, and the numsections
property set to
n
.
creates a cic decimation 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 combination.cicdecim
= dsp.cicdecimator(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 .
decimationfactor
— decimation factor
2
(default) | positive integer
factor by which the input signal is decimated, 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 a built-in integer data type, the decimation factor must be the same integer
data type or double
. for example, if the differential delay is an
int8
, then the decimation 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 andcicdecimout
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 thecicdecimout
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 '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 fixedpointdatatype
property to 'specify word and fraction lengths'
.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
usage
description
decimates the input using a cic decimator.cicdecimout
= cicdecim(input
)
input arguments
input
— data input
vector | matrix
data input, specified as a vector or matrix. the number of rows in the input must
be a multiple of the decimationfactor. 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
cicdecimout
— cic decimator output
vector | matrix
decimated output, returned as a vector or a matrix. the output frame size equals
(1 ∕ decimationfactor
) × 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
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.
the 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 the outputwordlength property. the output fraction
length, floutput, is given by:
specify word and fraction lengths
when the fixedpointdatatype
property 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
property 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:
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.cicdecimator
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.cicdecimator.helpfilteranalysis
in the matlab® command prompt. for the corresponding function reference pages, see .
examples
decimate a signal using a cicdecimator object
create a dsp.cicdecimator
system object™ with decimationfactor
set to 4. decimate a signal from 44.1 khz to 11.025 khz.
cicdec = dsp.cicdecimator(4);
cicdec.fixedpointdatatype = 'minimum section word lengths';
cicdec.outputwordlength = 16;
create a fixed-point sinusoidal input signal of 1024 samples, with a sampling frequency of 44.1e3 hz.
fs = 44.1e3;
% 0.0232 sec signal
n = (0:1023)';
x = fi(sin(2*pi*1e3/fs*n),true,16,15);
create a dsp.signalsource
object.
src = dsp.signalsource(x,64);
decimate the output with 16 samples per frame.
y = zeros(16,16); for ii = 1:16 y(ii,:) = cicdec(src()); end
plot the first frame of the original and decimated signals. output latency is 2 samples.
d = cicdec.decimationfactor; diffdelay = cicdec.differentialdelay; numsect = cicdec.numsections; gaincic = ... (d*diffdelay)^numsect; stem(n(1:56)/fs,double(x(4:59))) hold on; stem(n(1:14)/(fs/d),double(y(1,3:end))/gaincic,... 'r','filled') xlabel('time (sec)') ylabel('signal amplitude') legend('original signal',... 'decimated signal',... 'location','north') hold off;
using the info
method in 'long'
format, obtain the word lengths and fraction lengths of the fixed-point filter sections and the filter output.
info(cicdec,'long')
ans = 'discrete-time fir multirate filter (real) ----------------------------------------- filter structure : cascaded integrator-comb decimator decimation factor : 4 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 : 2.5 fixed-point info section word lengths : 20 19 19 18 section fraction lengths : 15 14 14 13 output word length : 16 output fraction length : 11 '
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 decimation filter is conceptually given by a single rate cic filter, h(z) which is a lowpass anti-imaging filter, followed by a downsampler. the cic decimation filter decreases 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,
hi is the transfer function of the integrator part of the filter containing n stages of integrators.
hc is the transfer function of the n sections of the cascaded comb filters, each with a width of rm.
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 decimation factor.
m is the differential delay.
in the overall multirate realization, the algorithm applies the noble identity for decimation and moves the rate change factor, r, to follow after the n sections of the cascaded integrators. 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.cicdecimator
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 decimation filter
the cic decimation filter in more about is realized as a cascade of n sections of the integrators followed by a rate change factor of r, followed by n sections of comb filters.
this diagram shows two sections of cascaded integrators and two sections of cascaded comb filters. 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 block puts the unit delay in the feedforward path of the integrator because 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)
- 中国
- (日本語)
- (한국어)