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: Ben Abbott
Subject: Re: Another request for classdef test in Matlab
Date: Fri, 04 Jan 2013 17:41:22 -0500

On Jan 4, 2013, at 5:26 PM, Michael Goffioul wrote:

> Can anyone test the following in Matlab.
> 
> Have a class defined in ClassA.m as:
> 
> classdef ClassA < handle
>   properties
>     x = 1;
>   end
>   methods
>     function obj = ClassA (x)
>       obj.x = x;
>     end
> end

I had a few minutes to get back to this today.  Looks like I'm helping with the 
easy parts ;-)

You missed an "end"

classdef ClassA < handle
  properties
    x = 1;
  end
  methods
    function obj = ClassA (x)
      obj.x = x;
    end
  end
end


> At the prompt, execute:
> 
> a(2,2) = ClassA (2)

a(2,2) = ClassA (2)
Error using ClassA (line 7)
Not enough input arguments.

> a.x      <===== note that this might fail, I don't know
> a(1,1).x, a(2,2).x
> a(1,1) == a(1,2)
> h = a(1,1)
> h.x = 3
> a(1,1).x, h.x
> 
> Michael.
> 



reply via email to

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