reshape vector to matrix

3 visualizaciones (últimos 30 días)
Anurag Gupta
Anurag Gupta el 25 de Oct. de 2020
Comentada: Anurag Gupta el 27 de Oct. de 2020
I want to convert
d = [1 2 3 4 5]
to d = [1 2
2 3
3 4
4 5]
is there anyway I can do it.

Respuesta aceptada

Stephen23
Stephen23 el 25 de Oct. de 2020
A general solution for an arbitrary number of rows and columns:
>> d = [1,2,3,4,5];
>> r = 4;
>> m = hankel(d(1:4),d(r:end))
m =
1 2
2 3
3 4
4 5

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by