octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can we deprecate/remove extra arguments currently accepted by numel?


From: Kai Torben Ohlhus
Subject: Re: Can we deprecate/remove extra arguments currently accepted by numel?
Date: Fri, 15 Mar 2019 08:28:37 +0100

On Fri, Mar 15, 2019 at 5:38 AM John W. Eaton <address@hidden> wrote:
Octave's numel function accepts extra arguments:

[...] For example,

           A = 1;
           B = ones (2, 3);
           numel (A, B)

      will return 6, as this is the number of ways to index with B.  Or
      the index could be the string ":" which represents the colon
      operator.  For example,

           A = ones (5, 3);
           numel (A, 2, ":")

      will return 3 as the second row has three column entries [...]

Does Matlab still accept this usage?  It does not appear to be
documented now.

Both examples still work in R2018b with the same results (the second example with ':' single quotes).

The documentation is not really clear about how numel is used today, but in the context with classes the ML docs clearly suggest to use "numArgumentsFromSubscript", even if a numel-method is present:

"If classes implement a numArgumentsFromSubscript method, MATLAB calls it instead of numel to determine the number of elements returned by indexed expressions that return comma-separated lists." [2].

Kai

[1] https://www.mathworks.com/help/matlab/ref/numargumentsfromsubscript.html
[2] https://www.mathworks.com/help/matlab/matlab_oop/understanding-size-and-numel.html#bup56_d
[3] https://www.mathworks.com/help/matlab/matlab_oop/overloading-numel-subsref-and-subsasgn.html

reply via email to

[Prev in Thread] Current Thread [Next in Thread]