octave-maintainers
[Top][All Lists]
Advanced

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

Re: Classdef Matlab test


From: Michael Goffioul
Subject: Re: Classdef Matlab test
Date: Wed, 22 May 2013 16:52:07 -0400

On Wed, May 22, 2013 at 4:01 PM, Laurent Hoeltgen <address@hidden> wrote:
On 22/05/13 21:53, Michael Goffioul wrote:
Could anyone test the following for me? Let's say you have the following
class:

ClassA.m:

classdef ClassA
   properties
     y = 10;
   end
end

Then at matlab prompt:

x = ClassA()
x(2,2).y = 20
x.y

z(2,2) = ClassA()
z(2,2).y = 20
z.y

Thanks,
Michael.


Hi,

I get the following output:

>> x = ClassA()

x =

  ClassA

  Properties:
    y: 10

  Methods

>> x(2,2).y = 20

x =

  2x2 ClassA

  Properties:
    y

  Methods

>> x.y

ans =

    10


ans =

    10


ans =

    10


ans =

    20

>> z(2,2) = ClassA()

z =

  2x2 ClassA

  Properties:
    y

  Methods

>> z(2,2).y = 20

z =

  2x2 ClassA

  Properties:
    y

  Methods

>> z.y

ans =

    10


ans =

    10


ans =

    10


ans =

    20

>>


Running MATLAB R2012a.

Regards,
Laurent

Thanks. Could you also try this variant?

ClassA.m:

classdef ClassA
  properties
    y;
  end
end

At prompt:

x = ClassA()
x(2,2).y.a = 10

z(2,2) = ClassA()
z(2,2).y.a = 10

Michael.


reply via email to

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