Question about OOP in Matlab?

Question about OOP in Matlab?

Post by Kevin Hu » Fri, 30 Aug 2002 02:35:37



Is it possible to have a "private" class? That is a class which is
only accessible by one class but not anyone else. For example, can I
achieve this by putting a class directory inside the private directory
of another class?

Thanks.

 
 
 

Question about OOP in Matlab?

Post by Dan Hensle » Fri, 30 Aug 2002 02:46:09



> Is it possible to have a "private" class? That is a class which is only
> accessible by one class but not anyone else. For example, can I achieve
> this by putting a class directory inside the private directory of
> another class?

> Thanks.

According to the subsection "Private Methods" in the Matlab documentation
under "Programming and Data Types", "Matlab Classes and Objects", you
can.  It also tells you how.

Dan

 
 
 

Question about OOP in Matlab?

Post by Joe Sabab » Fri, 30 Aug 2002 04:28:18




>> Is it possible to have a "private" class? That is a class which
is only
>> accessible by one class but not anyone else. For example, can I
achieve
>> this by putting a class directory inside the private directory
of
>> another class?

>> Thanks.

> According to the subsection "Private Methods" in the Matlab
documentation
> under "Programming and Data Types", "Matlab Classes and Objects",
you
> can.  It also tells you how.

> Dan

Hi,
You can find the caller address and filter the directory of the
caller. To find the caller you can use:
1. S1=dbstack; [S,F,E]=fileparts(S1(2).name);
2. S=evalin('caller',pwd)

return
end
The nice thing about this method that it can allow also filtering of
folders that are not classes, or sharing functions between several
classes.
If you use an object "private" you need only to put the filter at the
constructor. In this case it may be that you can use only dbstack
mathod with the third element (S(3).name). Check it.

Joe
BSTEX - Equation viewer for Matlab
 <http://www.geocities.com/bstex2001>

 
 
 

Question about OOP in Matlab?

Post by Kevin Hu » Fri, 30 Aug 2002 07:44:53


I am not sure if I understand you correctly. Does that section only
mention about the private method of a class? What I want is the class
itself to be private.


> > Is it possible to have a "private" class? That is a class which is only
> > accessible by one class but not anyone else. For example, can I achieve
> > this by putting a class directory inside the private directory of
> > another class?

> > Thanks.

> According to the subsection "Private Methods" in the Matlab documentation
> under "Programming and Data Types", "Matlab Classes and Objects", you
> can.  It also tells you how.

> Dan

 
 
 

Question about OOP in Matlab?

Post by Dan Hensle » Fri, 30 Aug 2002 09:15:05



> I am not sure if I understand you correctly. Does that section only
> mention about the private method of a class? What I want is the class
> itself to be private.

If I understand the documentation correctly, you can create the entire
private class in the "private" subdirectory of the class from which you
wish to call it.  Then it will only be available from that class.  So I
guess I'm not entirely sure, but it would be easy enough to test.  Now
that I read your initial post again, I see what you're asking.

Dan




>> > Is it possible to have a "private" class? That is a class which is
>> > only accessible by one class but not anyone else. For example, can I
>> > achieve this by putting a class directory inside the private
>> > directory of another class?

>> > Thanks.

>> According to the subsection "Private Methods" in the Matlab
>> documentation under "Programming and Data Types", "Matlab Classes and
>> Objects", you can.  It also tells you how.

>> Dan

 
 
 

1. Newbie OOP Matlab question

Hi!

I'm trying to program using Matlab by employing an Object Oriented approach.
I have already programmed in C++ and am having some "adjustment problems".

All I want to do is define/declare a class and have that class contain a public method.
For example :

class Airplane {
    public :
        fly() {};

In C++ one would simply:

Airplane aPlane;
aPlane.fly();

As best as I can tell, Matlab doesn't allow this kind of action... (please tell me if I'm wrong).
In Matlab one *can* create an mfile that contains the function "fly"... but I THINK you'd
have to have a variable of type "Airplane" in the parameter list in order for the correct object to
be operated on/accessed.

Now that I have written this whole thing.... it seems pretty straightforward..... but could someone
verify that I have this right? (Or even close ;-) )

Thanks!

Dan Samber

2. FTP problems

3. OOP related question ...

4. darkscan.raw

5. OOP in Matlab

6. Objective C for Windows ?

7. OOP in MATLAB

8. Sql Server and W2000

9. Matlab OOP, subsref

10. Security for MATLAB OOP code

11. Matlab OOP and polymorphism

12. OOP in Matlab

13. oop and matlab