www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SubscriptsAndValuesForNonzeroElementsExample.m

    %% 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.

% Copyright 2015 The MathWorks, Inc.

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

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