Should I put get / set methods in class definition in Matlab?

Is it forced to place all the get and set functions in the class definition file in Matlab?

I ask because it really makes the file a little dirty and defeats the goal of having a class definition folder.

+5
source share
2 answers

Yes, if you use a set of properties and get access methods (virtually any method with a dot in the name), you should include them in a file classdef, not in separate files. See the documentation.

However, if you have a special reason to put as much as possible in individual files, you can define methods getMyPropand setMyPropin separate files, and then in the file classdef, type get.myPropand set.myPropchallenges.

+4
source

If you use them, you need to identify them. but you can also define your variables as public.

0
source

All Articles