Is one forced to place all get and set functions in the class definition file in Matlab ?
I'm asking since this really makes the file a bit messy and defeats the purpose of having a class definition folder.
Yes, if you use property set and get access methods (in fact any method with a dot in the name), you must include them within the classdef
file, not in separate files. See the documentation.
However, if you have have a special reason to want to put as much as possible in separate files, you can define methods getMyProp
and setMyProp
in separate files, and then within the classdef
file have the get.myProp
and set.myProp
functions call them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With