TONGUE:
I am writing object oriented code in MATLAB. I wrote almost all of this, and now, trying to test it, I am faced with what looks like a very fundamental problem.
CODE BACKGROUND:
I have a Window class and a Tracker class. Both are subclasses of the Singleton class (i.e., they have private constructors that provide only one instance of the Window class and class Tracker).
I create an instance of each of them, so now I have an object myWindow and myTracker.
In my main script, I call the myWindow.isNewbead () method. isNewbead is a public method of the Window class.
This is the scene. Now the problem is:
PROBLEM:
Inside isNewbead (), I call myTracker.getpredictedPositions (). getpredictedPositions () is a public method of the Tracker class. However, when I run this line, I get the error "myTracker" undefined. And, of course, I look at the workspace for variables, and the only variables are INSIDE local variables myWindow.isNewbead ();
So, I now have two questions:
QUESTIONS:
Is this true for OOP? That is, you cannot call a public method for an object from inside the method in another object without explicitly passing the first object to the method of the second object? It seems to me that I have a lot of trouble, because I use the properties and methods of many objects of different classes in each method, so I have to transfer hundreds of objects every time!
If this is only a MATLAB-related issue (for example, a non-static variable problem), then how can I do this?
Thank you very much!
Sincerely.
source share