MATLAB: How to find an element in a subset of a matrix as well as its index in the matrix

matrix indexing

Hi,
I am trying to find an element in a subset of a matrix (e.g. A) and the index of that element in matrix A.
Here is an example: let A be 6×6 matrix. I want to find a zero between rows 1 and 3, and columns 1 and 3.
I tried q = (find(A(1:3,1:3) == 0)
The answer I get is an array of 1 and 0, giving me an index of each 0 in terms of the subset of A that I defined. How can I find the index in terms of A?
thank you, i.

Best Answer

subset=false(size(A));
subset(1:3,1:3)=true;
indexLogical=(A==0) & subset;
q = find(indexLogical);