Sepideh
Sepideh

Reputation: 133

How to call member function of class in another m file in matlab?

How can call class function,and initialize object of class in another file.m , when calling from command window its work but I wanna call function from m file.

i have folder:@myClassName.

Upvotes: 2

Views: 423

Answers (2)

foozhan
foozhan

Reputation: 85

if you declare your object in a function you must return an output argumant of your function you can see the result in workspace

Upvotes: 2

gire
gire

Reputation: 1105

Since you say it works from the command window, then most likely the problem is the path. The folder containing the class-folder @myClassName must be in the path (see function addpath). From the other file you just need to:

my_instance = myClassName(...) % ... represent the inputs to your constructor.
my_instance.MyFunction(...);

Upvotes: 0

Related Questions