reshape vector to matrix

조회 수: 6 (최근 30일)
Anurag Gupta
Anurag Gupta 2020년 10월 25일
댓글: Anurag Gupta 2020년 10월 27일
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.

채택된 답변

Stephen23
Stephen23 2020년 10월 25일
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
  댓글 수: 1
Anurag Gupta
Anurag Gupta 2020년 10월 27일
Thanks a lot Stephen.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by