views:

33

answers:

3

I am working with the finacial tooldbox that has a type called FINTS, If I copy some code out of its toolbox directory to customize it, when I try do do something like fts.data, I get The specified field, 'data', does not exist in the object. But the same thing works fine in the matlab library directory. They are both in my path, so what else do I need to change? Thanks.

A: 

Make sure the path is specified from the root directory, and not relative.

For instance

addpath 'c:\...\...\MATLAB\mytoolbox

not

addpath 'mytoolbox'

the latter will break if you change your working directory

Marc
All my paths are not relative, but I don't think this problem is a path thing, since I can run scripts fine out of either directory. But it doesn't seem to know what a FINTS is outside of the @fints/ directory.
CptanPanic
+1  A: 

I think, but I haven't checked the docs on this one, that it is a peculiarity of Matlab that the class FINTS must be defined in the directory @fints. So if you want to extend the class you have to put your code into that directory. And if you want to work on a class MYFINTS, you need to put the code into directory @myfints.

High Performance Mark
+1  A: 

Ok I figured it out. Matlab defines class methods in what it calls method directories which are named after the class. So in this case the class is fints, so all its methods are in @fints. All I had to do was make a new directory in my own workspace called @fints, and it will become another class method of fints. You can see all the methods a class has by calling what className

CptanPanic
I would be wary about making multiple @-folders if you are using a newer version of MATLAB. Here is a quote from the end of [this online documentation](http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/brfynrp-1.html#brfynrp-4): "In MATLAB Versions 5 through 7, @-folders do not shadow other @-folders having the same name, but residing in later path folders. Instead, the class is defined by the combination of methods from all @-folders having the same name. **This is no longer true.** " The example given at that link illustrates this.
gnovice

related questions