problem of matrix operations
조회 수: 1 (최근 30일)
이전 댓글 표시
i have a n*n matrix. i want to obtain (row number-column number) matrix.for a 4*4 matrix result should be
[0 -1 -2 -3;
1 0 -1 -2;
2 1 0 -1;
3 2 1 0];
i want to do this for any (n*n) matrix.is there any method to do this.
댓글 수: 0
채택된 답변
Honglei Chen
2013년 9월 30일
You can do
rownumber = 4
colnumber = 4
bsxfun(@minus,(1:rownumber)',1:colnumber)
Or considering the special form of this matrix, you can just do
toeplitz((0:rownumber-1)',0:-1:-colnumber+1)
추가 답변 (2개)
참고 항목
카테고리
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!