octave-maintainers
[Top][All Lists]
Advanced

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

Re: Can someone test this for me in MATLAB?


From: Michael Goffioul
Subject: Re: Can someone test this for me in MATLAB?
Date: Fri, 4 Jan 2013 11:35:58 -0500

On Fri, Jan 4, 2013 at 11:31 AM, Michael D. Godfrey <address@hidden> wrote:
On 01/04/2013 10:33 AM, Michael Goffioul wrote:
Can anyone else help here?

I'd also like to know what happens when the class definition file changes due to path change:
1) have a class definition in the path; create an object of that class; change path such that the class definition file is not accessible anymore; is the object still valid? is it possible to create more objects of the class?
2) a variant of 1) is to have a superclass disappearing from the path, while the subclass is still available
3) a variant of 1) is when another class definition with the same name appears in the path: let's say you have 2 different class definitions d1/ClassA.m and d2/ClassA.m (with different methods and/or properties), then "addpath d1; x = ClassA(); rmpath d1; addpath d2; y = ClassA();";
4) a variant of 3) is to have a different superclass due to path change, while the subclass stays the same: you have ClassB.m, d1/ClassA.m and d2/ClassA.m, with ClassB inheriting from ClassA; then "addpath d1; x = ClassB(); rmpath d1; addpath d2; y = ClassB();"
5) a variant of 4) is without creating objects, simply accessing the metaclass with "?ClassB"

Michael.

I created the file:
[qss:octave_test] more test_class_p.m
classdef ClassC < handle

   properties
     p1 = 0;
     p2 = 1;
   end
end

in the Matlab path and got:
>> ?ClassC


ans =

  0x0 empty meta.class handle
  Package: meta

  Properties:
    Name
    Description
    DetailedDescription
    Hidden
    Sealed
    ConstructOnLoad
    InferiorClasses
    Properties
    Methods
    Events
    SuperClasses
    ContainingPackage


>> y=ClassC()
??? Undefined function or variable 'ClassC'.

>>
Should the definition have been in a @-folder?

I need pretty explicit description of what is needed since I have
not used Matlab Class stuff.

When using classdef, the filename must match the class name. So your file must be called ClassC.m. You can put it as a regular file into your path, or you can put it into a @ClassC folder (but still named ClassC.m). The use of @-folder only allows to have method definition in separate files, though they must still be declared in the classdef file.

Michael.


reply via email to

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