When we talk about Circular Convolution in digital signal processing, we try to write the MATLAB program.
According to the formula of Circular Convolution:
X1 (m) does not need to be changed. The difficulty is how to express X2 (n-M), which requires both reversing along the Y axis and periodic delay, in addition, it is OK to read the numbers 0-n-1 using the rectangular sequence.
By using the MOD function flexibly, you can achieve your goal.
By the way, the difference between mod and REM is that MoD and REM are the same for integers and 0, but there is a difference between negative numbers. The difference lies in their definition:
REM (x, y)IfY ~ = 0, ReturnsX-N. * yWhereN = fix (X./y)
MoD (x, y)IfY ~ = 0, ReturnsX-N. * yWhereN = floor (X./y)
You can see through the example:
MoD (4, 3) = 1 rem (4, 3) = 1
MoD (4,-3) = 2 REM (4,-3) = 1
MoD (-4, 3) =-1 rem (-4, 3) =-1
MoD (-4,-3) =-2 REM (-4,-3) =-1
To convert x = [1 2 3 4 4 5] from x 0-4 to a value of-4-0 [5 4 3 2 1], the MOD function can be applied if y = [1 5 4 3 2] with a period extension of 0-4.
Because the table 1 in the matrix is not 0
Y = x (mod (-[0: 4], 5) + 1); then the goal is achieved, that is, y = x (1 5 4 3 2 );
The same y = x (ABS (mod ([0: 4],-5) + 1) is also possible, and it is not that convenient for REM.
This is where n = 0.
N = 1 is y = x (mod ([0: 4]-) + 1 );
Similarly, n = 2 is y = x (mod ([0: 4]-) + 1 );......
The rest will be multiplied, and then the sum will be good, or use REM, Mod!
In addition, some operations on the coordinate axes are quite useful during the drawing time. I searched the internet and summarized the following useful operations:
1. Just want to display the axis xxxx
Set (GCA, 'xticket', [0: 1: N]); or display specific numbers (GCA, 'xticket', [a B c d]); or set (GCA, 'xtivklabel', {'A', 'B', 'C'}); or even
Set (GCA, 'xticicklab', sprintf ('', get (GCA, 'xticick ')));
2. let the coordinate axis have a small grid like a ruler. Set (GCA, 'xminick ick', 'on') can also determine whether the direction of the tick is outward or inward set (GCA, 'tickdir ', 'Out/in ');
Set (GCA, 'ticklength', [a B])(What does B mean?A is the length ).
3. Reverse the coordinate axis and its position
Set (GCA, 'xdir', reverse)
Place the X axis on the top, the Y axis on the left, and so on.
Set (GCA, 'axislocation', 'top') Set (GCA, 'axislocation', 'right ')
4. coordinate axes need to negotiate mathematical formulas and upper and lower coordinates.
Subscript of a: A _ {} a superscript: A ^ {}
Latex is a good summary. Here