MATLAB: Is anyone know, how to know the matrix coordinate..

matrix

is anyone know, how to know the matrix coordinate..?
a = [1 1 0; 0 0 0; 0 0 1;];
1 have coordinate on, (1,1) (1,2) and (3,3)
how to know the matrix coordinate..?

Best Answer

  • a = [1 1 0; 0 0 0; 0 0 1;];
    idx = find(a==1); % linear coordinates
    [I,J] = ind2sub(size(a),idx);
    The I,J pairs are the "matrix coordinates"