How can I store rotating index in a square matrix?

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 12 de Jul. de 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).

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by