필터 지우기
필터 지우기

How to compute the indices of a square matrix?

조회 수: 2 (최근 30일)
Xh Du
Xh Du 2017년 7월 25일
댓글: Xh Du 2017년 7월 26일
Hi all,
Imagine I have indices: i, j, k, l, I write
for i = 1:1
for j = 1:1
for k = 1:2
for l = 1:2
SOME OPERATIONS
end
end
end
end
From SOME OPERATIONS I'd like to find the indices for a 3 by 3 matrix, i.e by some operations of "i j k l", I can find:
1, 1
1, 2
1, 3
2, 1
2, 2
2, 3
3, 1
3, 2
3, 3
(of course not necessarily in this order)
I tried to replace SOME OPERATIONS with
disp([i + k , j + l])
it only gives me
1 1
1 2
2 2
1 1
1 3
2 3
1 1
1 2
3 2
1 1
1 3
3 3
not what I want, any ideas?

답변 (2개)

Rafael Hernandez-Walls
Rafael Hernandez-Walls 2017년 7월 25일
Deal with the following code:
i=1;
j=1;
for k=0:2
for l=0:2
disp([i+k,j+l])
end
end

Image Analyst
Image Analyst 2017년 7월 26일
Check out line 126 and 129 of my attached manual convolution code. It does what you want - it gets the indices of each point as you scan the matrix with a 3x3 window.
  댓글 수: 1
Xh Du
Xh Du 2017년 7월 26일
Hi,
This is a really complex code, would you please demo with the simple example I gave? Thanks!

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by