%% Subscripts and Values for Nonzero Elements
% Find the nonzero elements in a 3-by-3 matrix. Specify three outputs to return the row subscripts, column subscripts, and element values.

X = [3 2 0; -5 0 7; 0 0 1]

%

[row,col,v] = find(X)

% Copyright 2015 The MathWorks, Inc.