Home > custom > grid_tools > msize.m

msize

PURPOSE ^

PURPOSE: calculate total number of elements of a n-dimensional matrix.

SYNOPSIS ^

function s = msize(M)

DESCRIPTION ^

 PURPOSE: calculate total number of elements of a n-dimensional matrix.
          This is exactly what numel() does, only I didn't know before...
 ------------------------------------------------------------------------
 USAGE: s = msize(M)
 where: [M] is the Matrix to calculate no of elements for
-------------------------------------------------------------------------
 OUTPUTS:
        [s] size in cells (total number of elements)
 ------------------------------------------------------------------------

 See also: size(), numel()

 Felix Hebeler, Geography Dept., University Zurich, Juli 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function s = msize(M)
0002 % PURPOSE: calculate total number of elements of a n-dimensional matrix.
0003 %          This is exactly what numel() does, only I didn't know before...
0004 % ------------------------------------------------------------------------
0005 % USAGE: s = msize(M)
0006 % where: [M] is the Matrix to calculate no of elements for
0007 %-------------------------------------------------------------------------
0008 % OUTPUTS:
0009 %        [s] size in cells (total number of elements)
0010 % ------------------------------------------------------------------------
0011 %
0012 % See also: size(), numel()
0013 %
0014 % Felix Hebeler, Geography Dept., University Zurich, Juli 2006.
0015 
0016 dims=size(size(M),2);
0017 s=1;
0018 for i=1:dims
0019     s=s*size(M,i);
0020 end

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003