| Contents | Index |
c = conv(a,b)
c = conv(a,b,'shape')
c = conv(a,b) outputs the convolution of input vectors a and b, at least one of which must be a fi object.
c = conv(a,b,'shape') returns a subsection of the convolution, as specified by the shape parameter:
full — Returns the full convolution. This option is the default shape.
same — Returns the central part of the convolution that is the same size as input vector a.
valid — Returns only those parts of the convolution that the function computes without zero-padded edges. In this case, the length of output vector c is max(length(a)-max(0,length(b)-1), 0).
The fimath properties associated with the inputs determine the numerictype properties of output fi object c:
If either a or b has a local fimath object, conv uses that fimath object to compute intermediate quantities and determine the numerictype properties of c.
If both a and b are associated with the global fimath, conv uses the global fimath to compute intermediate quantities and determine the numerictype properties of c.
If either input is a built-in data type, conv casts it into a fi object using best-precision rules before the performing the convolution operation.
The output fi object c is always associated with the global fimath.
Refer to the MATLAB conv reference page for more information on the convolution algorithm.
The following example illustrates the convolution of a 22-sample sequence with a 16-tap FIR filter.
First, make sure the SumMode of the global fimath is set to FullPrecision:
globalfimath('SumMode', 'FullPrecision');Next, define the variables:
x is a 22-sample sequence of signed values with a word length of 16 bits and a fraction length of 15 bits.
h is the 16 tap FIR filter.
u = (pi/4)*[1 1 1 -1 -1 -1 1 -1 -1 1 -1]; x = fi(kron(u,[1 1])); h = firls(15, [0 .1 .2 .5]*2, [1 1 0 0]);
Because x is a fi object, you do not need to cast h into a fi object before performing the convolution operation. The conv function does so using best-precision scaling.
Finally, use the conv function to convolve the two vectors:
y = conv(x,h);
The operation results in a signed fi object y with a word length of 36 bits and a fraction length of 31 bits. The fimath properties associated with the inputs determine the numerictype of the output. In this case, both inputs are associated with the global fimath, so the global fimath determines the numerictype of the output.

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |