source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/qtfm/@quaternion/numel.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.3 KB
Line 
1function n = numel(q, varargin)
2% NUMEL   Number of elements in an array or subscripted array expression.
3% (Quaternion overloading of standard Matlab function.)
4
5% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
6% See the file : Copyright.m for further details.
7
8error(nargchk(1, inf, nargin)), error(nargoutchk(0, 1, nargout))
9
10% The built-in function numel, if applied to a quaternion array, always
11% returns 1. Clearly, the function should return the number of quaternions
12% in the array. Therefore, this is what we compute if this function is
13% called with a single argument (which can only be a quaternion array).
14
15if isempty(q) n = 0; end % Return zero for an empty quaternion array.
16
17if nargin == 1
18    n = prod(size(q)); % This gives the number of quaternions in q.
19else
20    % We have more than one argument. This means varargin represents a
21    % list of index values. See the Matlab help documentation on the
22    % numel function for a detailed (if unclear!) explanation of what
23    % numel has to do. It appears that this function should never be
24    % called with this parameter profile (Matlab calls the built-in
25    % function instead), so we trap a call with an error.
26
27    error('Quaternion numel function called with varargin, unexpected.');
28
29    % If we do have to handle this case, here is how it could be done:
30
31    n = numel(x(q), varargin);
32end
Note: See TracBrowser for help on using the repository browser.