Circular Convolution using C and MATLAB
Last Updated :
02 Aug, 2024
Involvement in preparing for and utilizing the modulator of the flag can be explained using the term circular convolution. It is a convolution technique that assumes signals to repeat themselves throughout, which makes it quite effective in cyclic data applications or signal systems that are folding back from end to start. This fact is important in various real-life situations like periodic signal analysis, digital filter design, and efficient implementation of convolution through Fast Fourier Transform (FFT).
In this article, we will look at what circular convolution means and discuss about its definition, types, working principle as well as components involved among others. The article will also show how C and MATLAB languages have been used to implement the concept of circular convolution with relevant examples and diagrams provided for easy understanding. By the time readers finish going through this piece of writing they will have got comprehensive knowledge on circular convolution’s applications and importance with respect to signal processing field.
What is Circular Convolution?
Another name for circular convolution is cyclic convolution; it happens when input signals are treated as if they are cyclical. On the other hand, linear convolution assumes that the signals persist into infinity with zero padding whereas circular convolution assumes that the signals continue from the start again when they reach at the end. For two periodic discrete-time signals x[n] and h[n]with period N, numerically, y[n] is defined as:
y[n] = (x ∗ h)[n] = m=0∑n=1 x[m] h [(n−m) mod N]
Types of Circular Convolution
Several types of circular convolutions exist based on different characteristics in their input.
- Discrete-Time Circular Convolution: Involves periodic discrete signals.
- Continuous-Time Circular Convolution: Deals with continuous periodic signals.
- Cyclic Convolution in Finite Fields: Used in coding theory and cryptography.
Working Principle
Steps involved in circular convolution are:
- Period Expansion: Present input signals in the form of discontinuities.
- Shifting and Wrapping: Move one signal by a single sample and wrap it back on itself when it reaches the end.
- Element-wise Multiplication and Summation: Multiply corresponding elements of the signals together then summing them to give each value of the output signal.
Parameters of Circular Convolution
- Input Signals: Signals that are being convolved.
- Shift Register: Something that moves the signals along and wraps them round at each end as they do so.
- Multiplier: It multiplies items element-by-element.
- Accumulator: Sums the bits together to obtain outgoing signal
Construction
To set up a circular convolution system, you should have:
- Something for representing and storing periodic signals .
- Something for doing cyclic shifts with wrapping points (the logic).
- Multipliers that do operations like multiplication between respective items.
- A collector, which combines duplications during wrap arounds
Key Terminologies
- Periodicity: Signal repeats itself after every defined period.
- Modulo Operation: This is useful in implementing wrapping around in circular convolution processing method.
- Circular Shift: A signal whose elements have been shifted with wrapping taking place.
Examples
Example in C
C
#include <stdio.h>
void circularConvolution(int x[], int h[], int y[],
int size)
{
for (int i = 0; i < size; i++) {
y[i] = 0;
for (int j = 0; j < size; j++) {
y[i] += x[j] * h[(i - j + size) % size];
}
}
}
int main()
{
int x[] = { 1, 2, 3, 4 };
int h[] = { 5, 0, 0, 0 };
int n = 4;
int y[n];
circularConvolution(x, h, y, n);
for (int i = 0; i < n; i++) {
printf("%d ", y[i]);
}
return 0;
}

Example in MATLAB
Matlab
x = [1, 2, 3, 4];
h = [5, 0, 0, 0];
N = length(x);
y = zeros(1, N);
for n = 1:N
for m = 1:N
y(n) = y(n) + x(m) * h(mod(n - m, N) + 1);
end
end
disp(y);
Output
5 10 15 20
OutputAdvantages and Disadvantages
Advantages
- Fast computation using FFT algorithmic approach is employed herein,
- Ideal for periodic waveform analysis purposes,
- Implementation becomes very easy while working on digital filters design or realization,
- Cyclic data handling can be attained.
- Some applications may have computational complexity reduced.
Disadvantages
- It can’t be used for non-periodic signals.
- Signal wrapping needs to be properly dealt with.
- The latter causes artifacts in the output.
- Linear convolution, compared to circular convolution, has a wider range of application areas.
- Difficulties in understanding and execution.
Applications
- Designing digital filters
- Processing signals in communication systems
- Audio signal processing
- Processing images
- Convolutional neural networks
- Periodic data analysis
- Error detection and correction in coding theory
- Cryptographic algorithms
- Radar signal processing
- Biomedical signal processing
Differences between Linear Convolution and Circular Convolution
Aspect | Linear Convolution | Circular Convolution |
---|
Signal Extension | Expect zero cushioning past the length of the flag. | Assumes periodic extension of the signal.
|
Length of Result | The result length is N+M−1 for input signals of lengths N and M. | The result length is the same as the input flag length, N. |
Computation Complexity | Requires more operations due to longer result length and zero padding. | More efficient with fewer operations due to periodic extension.
|
Application Context | Used in systems where the signals do not repeat, like image processing, audio signal processing. | Ideal for systems involving periodic or cyclic data, such as digital communications and filter design.
|
Frequency Domain | Linear convolution corresponds to multiplication in the frequency domain after zero-padding and taking the FFT of both signals. | Circular convolution corresponds to element-wise multiplication in the frequency domain without additional zero-padding, using the FFT directly.
|
Artifacts | No wrapping artifacts, but edge effects due to zero padding can occur. | Potential wrapping artifacts if signals are not properly handled, but avoids edge effects seen in linear convolution.
|
Implementation | Can be implemented using straightforward multiplication and summation, but less efficient compared to circular convolution for long signals. | Can be efficiently implemented using FFT, which converts convolution into element-wise multiplication in the frequency domain, significantly speeding up computation.
|
Conclusion
Circular Convolution is a very important operation in signal processing specially when dealing with periodic signals or cyclic data. Its fast computation using FFT makes it indispensable for a number of applications ranging from digital filters to communication systems. Understanding its basic principles, merits and drawbacks will help to realize its potential fully as an essential tool under consideration.
Similar Reads
Fast convolution for 64-bit integers Convolution is a mathematical operation used in signal processing, image processing, and other fields to combine two functions in order to produce a third function. It is defined as the integral of the product of two functions, one of which is flipped and shifted over time. It is often represented u
7 min read
Image Filtering Using Convolution in OpenCV Prerequisites: Basics of OpenCV, Basics of Convolution In this article, filtering of images using convolution in OpenCV (Open Source Computer Vision) is discussed. In order to use the OpenCV library in Python, the following libraries should be installed as a prerequisite: Numpy libraryMatplotlib lib
8 min read
Trigonometric Functions in MATLAB In this article, we are going to discuss trigonometric functions and their types in MATLAB. Trigonometric functions are the mathematical functions that can result in the output with the given input. There are six trigonometric functions - Sine (sin)Cosine(cos)Tangent(tan)CoTangent(cot)Secant(sec)Co
5 min read
Simulink in MATLAB MATLAB which is also known as "Matrix Laboratory" allows its user to manipulate matrixes, plotting of functions and data, creation of algorithms, and user interfaces written in different programming languages by providing a computing environment. MATLAB is software designed and powered by mathworks.
4 min read
How to subtract two images using Python-OpenCV ? In this article, we are going to see how to subtract two images using OpenCV in Python. Now, before getting into the topic we shall discuss some of the use cases of Arithmetic operations. Arithmetic operations like addition and subtraction can help us to make images brighter or darker. Specifically,
3 min read