필터 지우기
필터 지우기

how to arrange vector to matrix?

조회 수: 3 (최근 30일)
PaulLe
PaulLe 2021년 11월 6일
댓글: PaulLe 2021년 11월 7일
Hi guys,
I have a vector: x = [1 2 3 4 5 6]
How to arrange this vector to new matrix, like this:
[1 2 3 4 5 6
2 3 4 5 6 1
3 4 5 6 1 2
4 5 6 1 2 3]
Thanks for your help.

채택된 답변

Stephen23
Stephen23 2021년 11월 7일
x = [1,2,3,4,5,6];
m = hankel(x(1:4),x([4:6,1:3]))
m = 4×6
1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3
  댓글 수: 1
PaulLe
PaulLe 2021년 11월 7일
Thanks Sir. It was fine.

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

추가 답변 (1개)

Sudharsana Iyengar
Sudharsana Iyengar 2021년 11월 6일
You can try using the functions perms. or if you want cyclic permutations
x=[1,2,3,4,5,6];
v=perms(x)
v = 720×6
6 5 4 3 2 1 6 5 4 3 1 2 6 5 4 2 3 1 6 5 4 2 1 3 6 5 4 1 3 2 6 5 4 1 2 3 6 5 3 4 2 1 6 5 3 4 1 2 6 5 3 2 4 1 6 5 3 2 1 4
X=[1,2,3,4,5,6];
V=[X;circshift(X,1);circshift(X,2);circshift(X,3);circshift(X,4);circshift(X,5);]
V = 6×6
1 2 3 4 5 6 6 1 2 3 4 5 5 6 1 2 3 4 4 5 6 1 2 3 3 4 5 6 1 2 2 3 4 5 6 1
  댓글 수: 1
PaulLe
PaulLe 2021년 11월 7일
Thank you sir. But is there any other help?

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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by