% Demonstrates use of find command to make a scatter plot of 
% binary-valued matrix, i.e. where all points (i,j) such that 
% m(i,j) == 1 are plotted ...

% Generate random square matrix of zeros and ones ...
n = 200;
m = randi(2, n, n) - 1;

% Used as follows, find returns two vectors, xx and yy, each of a 
% length equal to the total number, nzero, of non-zero elements in m, 
% and such that
% 
%    mm(xx(i),yy(i)) ~= 0  for i = 1 : nzero
% 
% Type 'help find' for additional information about find.

[xx yy] = find(m);

% Make scatter plot of non-zero values ...
scatter(xx, yy, '.');
