Home > atmlab > math > rnnz.m

rnnz

PURPOSE ^

RNNZ Relative amount of non-zero elements

SYNOPSIS ^

function f = rnnz(x)

DESCRIPTION ^

 RNNZ   Relative amount of non-zero elements

    Works as *nnz* but returns the relative value, instead of the
    absolute number of non-zero values.

 FORMAT  f = rnnz(x)  
        
 OUT   f   Fraction of non-zero elements.
 IN    x   Data vector or matrix.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

rnnz.m

SOURCE CODE ^

0001 % RNNZ   Relative amount of non-zero elements
0002 %
0003 %    Works as *nnz* but returns the relative value, instead of the
0004 %    absolute number of non-zero values.
0005 %
0006 % FORMAT  f = rnnz(x)
0007 %
0008 % OUT   f   Fraction of non-zero elements.
0009 % IN    x   Data vector or matrix.
0010 
0011 % 2005-05-17   Created by Patrick Eriksson.
0012 
0013 function f = rnnz(x)
0014 
0015 f = length(find(x)) / prod(size(x));

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005