Wednesday, June 30, 2010

Matlab Class

What is a MATLAB class? Even though the MATLAB user’s guide does a good job of answering it, I hear this question a lot. After numerous discussions and mentoring sessions, I now realize that this is not really the intended question. Askers are really searching for a framework on which they can build their own classes. Other languages provide this type of framework, so it is natural to expect MATLAB to provide one too. The user’s guide doesn’t define such a framework, probably for good reason. It would require more detail than is typical for a user’s guide.

In C++ and Java, the framework is largely predefined by the language syntax. In MATLAB,
no such framework exists and the few required elements allow for a lot of customization. Unfortunately, this also means there is no single answer to exactly what constitutes a MATLAB class or what constitutes an acceptable framework. There is a range of answers that depend on the desired level of customization. Classes designed to do one particular job in some specific application do not need an extensive framework. Classes that are nearly indistinguishable from built-in types or classes implemented with an extensive reuse goal require a sophisticated framework. Both need to include the required elements, but the first requires fewer “optional” elements.

Another thing to consider is change. The object-oriented framework in this book is tailored for MATLAB versions 6.5 through 7.1. When version 7 was released, a beta version containing several improvements to the object framework was also released. The framework in the version 7 beta release and the framework developed in this book can peacefully coexist. Future releases of MATLAB will undoubtedly contain framework elements that improve the performance or organization of this book’s framework. This is a good thing, and from what I have seen, it should be easy to incorporate those improvements. Also, from what I have seen, there is a lot to like in the beta version of the framework. Future releases could also include elements that break this book’s framework. So far, there is no hint of a problem. The detailed descriptions and examples in this book will allow you to adapt to any new framework.

EXAMPLE : CLASS REQUIREMENTS
Currently there are only two requirements for creating a class: a directory that identifies the class, and an m-file that defines the data structure and returns an object. Central to both requirements is the name of the class. All class files are stored in a directory with a name that is essentially the name of the class, and the name of the class’ defining m-file is the same as the class name. Since the class name and the name of the defining m-file are the same, the naming restrictions for the class are identical to restrictions placed on functions: no punctuation, no spaces, cannot start with a number, and so on.
Andy H. Register

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

2 comments: on "Matlab Class"

Anonymous said...

Thanks for sharing wonderful post

You can access frequently asked interview question on c , c++ , java , data structure , databases on

http://www.gotaninterviewcall.com/

M.Nedi said...

thank`s for coming 2 my blog,, let`s share together.. happy blogging.

Post a Comment