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: Michael D. Godfrey
Subject: Re: Another request for classdef test in Matlab
Date: Sat, 05 Jan 2013 17:01:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 01/05/2013 04:23 PM, Michael Goffioul wrote:
Last test request. With the following class:

classdef ClassA
  properties
    x = 1;
  end
  methods
    function obj = ClassA (x)
      if nargin > 0
        obj.x = x;
      end
    end
  end
end

Execute the following at the prompt:

a(2,2) = ClassA(2)
b = a
c = a(1,1)
c.x = 3
a(1,1).x, b(1,1).x, c.x
a(1,1).x = 4
a(1,1).x, b(1,1).x, c.x

Michael.

Here it is :
>> a(2,2) = ClassA(2)

a =

  2x2 ClassA

  Properties:
    x


>> b = a

b =

  2x2 ClassA

  Properties:
    x


>> c = a(1,1)

c =

  ClassA

  Properties:
    x: 1


>> c.x = 3

c =

  ClassA

  Properties:
    x: 3


>> a(1,1).x, b(1,1).x, c.x

ans =

     1


ans =

     1


ans =

     3

>> a(1,1).x = 4

a =

  2x2 ClassA

  Properties:
    x


>> a(1,1).x, b(1,1).x, c.x

ans =

     4


ans =

     1


ans =

     3

>>
>> >> version

ans =

7.9.0.529 (R2009b)





reply via email to

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