octave-maintainers
[Top][All Lists]
Advanced

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

Re: Classdef Matlab test


From: Ben Abbott
Subject: Re: Classdef Matlab test
Date: Thu, 23 May 2013 00:26:34 +0000 (GMT)

On May 22, 2013, at 04:52 PM, Michael Goffioul <address@hidden> wrote:

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.
 
matlab> clear all
matlab> x = ClassA ()

x = 

  ClassA with properties:

    y: []

matlab> x(2,2).y.a = 10

x = 

  2x2 ClassA array with properties:

    y

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

z = 

  2x2 ClassA array with properties:

    y

matlab> z(2,2).y.a = 10

z = 

  2x2 ClassA array with properties:

    y

Ben

reply via email to

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