Matlab

# How to Perform Convolution and Polynomial Multiplication with MATLAB’s conv

Convolution or digital filtering is the most common mathematical operation widely used in modern signal processing. A cyclic or periodic convolution behaves like a product of two polynomials and it is widely used in block filtering techniques. Manually finding the convolution of two vectors or polynomials is a complicated operation; however, in the era of high-performance computing tools like MATLAB, it has become an easy task to calculate convolution using the conv() function.

Follow this guide to elaborate on how to perform convolution and polynomial multiplication using the conv() function.

## How to Perform Convolution and Polynomial Multiplication in MATLAB?

Finding the convolution or polynomial multiplication is a complicated mathematical operation that can be easily performed using the built-in conv() function. This function takes two vectors as a mandatory input and performs convolution on them.

## Syntax

MATLAB allows us to perform convolution and polynomial multiplication using the given syntaxes:

w = conv(a,b)
w = conv(a,b,shape)

Here:

• The function w = conv(u,v) computes the convolution of the given vectors a and b. If a and b represent coefficients of the polynomials, their convolution will be equivalent to the polynomial multiplication.
• The function w = conv(u,v,shape) computes a subsection of the convolution as specified by the variable shape.

## Example 1: How to Perform Polynomial Multiplication Via Convolution?

This MATLAB code calculates a product of two polynomials via convolution using the conv(a,b) function. The vectors a and b represent coefficient vectors of the polynomials:

respectively.

a = [2 1 -7];
b = [7 0 -2 1];
w = conv(a,b)

## Example 2: How to Calculate the Central Part of Vectors Consultation?

In this example, we create two vectors a and b, and compute their central convolution using the conv(a,b,shape) function.

a = randi(10,1,8);
b = randn(1,5);
w = conv(a,b,"same")

The above code creates a random vector of length 8 with elements between 1 and 10. The other function creates a random vector of length 5 with elements drawn from a normal distribution. It then calculates the central convolution function and returns the same vector of length.

## Conclusion

Convolution or polynomial multiplication is a complicated mathematical operation that is widely used in modern signal processing and block filtering methods. MATLAB can easily perform this operation using the built-in conv() function. This guide presented the implementation of the conv() function using different syntaxes and examples.