empty object indexing compatibility with Matlab

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

empty object indexing compatibility with Matlab

Rik-4
For most data types, an empty index returns the object itself.

--- Code ---
octave:7> x = 1:3
x =

   1   2   3

octave:8> x()
ans =

   1   2   3
--- End Code ----

However, for class objects the behavior is up to the programmer.  However,
I'd like to know if Matlab generally tries to maintain this behavior for
the classdef objects they write.

Could someone try the following code in Matlab?

--- Test Code ---
x = containers.Map (1, 2)
x()
--- End Test Code ---

Thanks,
Rik



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: empty object indexing compatibility with Matlab

NJank
On Fri, Aug 11, 2017 at 11:32 AM, Rik <[hidden email]> wrote:
> Could someone try the following code in Matlab?

matlab 2017b

>> x = 1:3

x =

     1     2     3

>> x()

ans =

     1     2     3

>> x = containers.Map(1,2)

x =

  Map with properties:

        Count: 1
      KeyType: double
    ValueType: double

>> x()
Error using containers.Map/subsref
Only one-dimensional indexing is supported.

Loading...