how do I create a matrix of array?
조회 수: 11 (최근 30일)
이전 댓글 표시
I want to create a matrix of data points like this
[0,0] [0,1] [0,2]
[1,0] [1,1] [1,2]
[2,0] [2,1] [2,2]
so that Ideally if I access the position (2,2) I'll get the array [1 1], which represent a point.
댓글 수: 0
답변 (1개)
Matt J
2017년 2월 19일
[I,J]=ndgrid(0:2,0:2);
A=reshape([I(:),J(:)].', [2,1,3,3]);
A=permute(A,[2,1,3,4]);
>> A(:,:,2,2)
ans =
1 1
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!