How can I store rotating index in a square matrix?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 12 Jul 2018
Answered: MathWorks Support Team
on 12 Jul 2018
For example, if I have index [1,2,3,4] how can I store it in a matrix such that each column represent these indices in rotation:
A = [1 2 3 4;
2 3 4 1;
3 4 1 2;
4 1 2 3];
Furthermore, the index I have is quite huge, which means A will can be a 1024 x 1024 in dimension.
Accepted Answer
MathWorks Support Team
on 12 Jul 2018
You can use the "hankel" function to create such matrix in MATLAB:
>> v = 1:4;
>> A = hankel(v, circshift(v,1))
Furthermore, the matrix A above is actually a skew-circulant matrix, which is a special type of Hankel matrix. In real-life application, these matrices rarely need to be explicitly computed, as they can be applied via cross-correlations (and especially in the case of a skew-circulant matrix, this can be done quite efficiently with the FFT).
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!