Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7087823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:43:18+00:00 2026-05-28T07:43:18+00:00

LANGUAGE: I am writing an object-oriented code in MATLAB. I wrote almost all of

  • 0

LANGUAGE:

I am writing an object-oriented code in MATLAB. I wrote almost all of it, and now when trying to test it, am running into what looks like a very fundamental issue.

BACKGROUND OF THE CODE:

I have a class Window and a class Tracker. Both are subclasses of the Singleton class (that is, they have private constructors to ensure that only one single instance of class Window and class Tracker are created).

I instantiate each of them- so I now have a myWindow and myTracker object.

In my main script, I call a method, myWindow.isNewbead(). isNewbead is a public method of class Window.

That’s the scene. Now the problem:

THE PROBLEM:

Inside isNewbead(), I call myTracker.getpredictedPositions(). getpredictedPositions() is a public method of class Tracker. However, when I run this line, I get an error saying variable ‘myTracker’ is undefined. And sure enough, I look in the variable workspace, and the only variables there are the local variables INSIDE myWindow.isNewbead();

So I now have two questions:

QUESTIONS:

  1. Is this true of OOP everywhere? That is to say, can you not call a public method on an object from inside a method in another object without explicitly passing the first object to the method of the second object? It seems like a lot of hassle to me, because I use properties and methods of lots of objects of different classes in every method, so I will have to end up passing hundreds of objects every time!

  2. If this is only a MATLAB-specific problem (like the problem of no-static-variables) then how do I work my way around it?

Thank you so much!

Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:43:18+00:00Added an answer on May 28, 2026 at 7:43 am

    Yes, you can call a public method of one object (object A) from a method of another object (object B) since it’s, well, public; however, you need to have a reference to object A to use within the object B method. Pass a reference to the object A as input argument to the object B method.

    It may seem like a hassle but how else could this work? Even though Tracker inherits from the Singleton class, myTracker is still just an instance of the Tracker object. You need a reference to this instance in order to use its methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this statement true?? Writing object oriented code, even in non-object oriented language. Can
I'm writing documentation for an object-oriented language, and I wonder what kind of classes
We want to design a simple domain specific language for writing test scripts to
I'm writing (in C#) a simple parser to process a scripting language that looks
This is a question about using an object-oriented language. I've been using C++ to
I'm writing a java package that will be called by another language (matlab). If
When writing object-oriented software, I use dependency injection a lot: to compose together high-level
I'm currently enjoying the transition from an object oriented language to a functional language.
I've recently been trying to learn the Object-Oriented aspects of F#, and have become
LaTeX is a wonderful language for writing documents. With the hyperref package and pdflatex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.