octave-maintainers
[Top][All Lists]
Advanced

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

Re: Another request for classdef test in Matlab


From: Philip Nienhuis
Subject: Re: Another request for classdef test in Matlab
Date: Fri, 4 Jan 2013 15:35:15 -0800 (PST)

Michael Goffioul wrote
> On Fri, Jan 4, 2013 at 5:57 PM, Ben Abbott <

> bpabbott@

> > wrote:
> 
>>
>> On Jan 4, 2013, at 5:44 PM, Michael Goffioul wrote:
>>
>> > On Fri, Jan 4, 2013 at 5:41 PM, Ben Abbott <

> bpabbott@

> > wrote:
>> >
>> > On Jan 4, 2013, at 5:26 PM, Michael Goffioul wrote:
> <snip>
> What about the rest of the commands?
> 
> Could you also try with this class:
> 
> classdef ClassA < handle
>   properties
>     x = 1;
>   end
>   methods
>     function obj = ClassA (x)
>       if nargin > 0
>         obj.x = x;
>       end
>     end
>     function value = get.x (obj)
>       disp ('get.x');
>       value = obj.x;
>     end
>   end
> end


ML2013a:

>> a(2,2) = ClassA (2)

a = 

  2x2 ClassA array with properties:

    x

>> a.x
get.x
get.x
get.x
get.x

ans =

     1


ans =

     1


ans =

     1


ans =

     2

>> a(1,1).x, a(2,2).x
get.x

ans =

     1

get.x

ans =

     2

>> a(1,1) == a(1,2)

ans =

     0

>> h = a(1, 1)

h = 

get.x
  ClassA with properties:

    x: 1

>> h.x = 3

h = 

get.x
  ClassA with properties:

    x: 3

>> a(1,1).x, h.x
get.x

ans =

     3

get.x

ans =

     3

>> 




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Another-request-for-classdef-test-in-Matlab-tp4648583p4648589.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

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