MATLAB: How to store [row,col]= find(X==a) results in a N*2 matrix ?!

find(x==a)

How can I store [row,col]= find(X==a) results in a N*2 matrix ?! I have a 100×100 matrix and I want to store the indices(i,j) of all elements from my 100×100 matrix they are equal 3 in another Nx2 matrix. I can extract indices with [row,col]= find(X==3) but I need the in a N*2 matrix.

Best Answer

Unless I’m missing something in your Question, I would create an (Nx2) matrix of the row and column indices as:
[row,col]= find(X==3);
Index_Mtx = [row col];