| Description |
Just like the FIND function in Matlab, FINDN is a simple function which will find the indices and values of nonzero elements in a n-D matrix
function [sub v] = findn(A)
% INPUT: A: n-D matrix
% OUTPUT: sub: the k x n index matrix (k is the number of the nonzeros)
v: a column or row vector v of the nonzero entries in A
USAGE:
[sub ] = findn(A)
TESTING CODE:
A = zeros(4,3,5,7);
A(4,2,1,4)=1;
A(2,3,4,6)=2;
A(1,2,3,4)=3;
findn(A)
AUTHOR:
Brian H. Hui (brianhui@alumni.usc.edu)
PhD candidate, Electrical Engineering, University of Southern California
|