


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.

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