Call a function in an m-file from a method of a handle class
Show older comments
I would like to know, if the object, which is being created with the help of the (handle) class methods, would also be visible for modifications in a function called from a method of the (handle) class, even if I don't pass the object itself to that function?
If the object is visible to the function called in a class method, so I can just work with it from the function using it's name from the class itself (using the name of the "constructor function")?
Or must I pass the object to the function called in the class method?...
Thank you for your answer in advance!
1 Comment
Ahmed Hossam
on 6 Apr 2017
Edited: Ahmed Hossam
on 6 Apr 2017
Accepted Answer
More Answers (1)
If you don't pass the object in then it has to be a static function and has knowledge of the class only, not the specific object. You can define class functions in separate files, although I can't remember what you need to do, I've never wanted to do it myself. It is mentioned somewhere in the large pdf file on Matlab OOP though (Section 5-2 seems to cover this)
2 Comments
Ahmed Hossam
on 6 Apr 2017
Guillaume
on 6 Apr 2017
It's not weird. I do it sometimes when the class are complex. It is much easier to locate a particular file than scroll through 1000s of lines in a single file.
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!