Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to put get/set methods in the class definition in matlab ?

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.

like image 364
Carel Avatar asked Oct 07 '22 14:10

Carel


1 Answers

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.

like image 125
Sam Roberts Avatar answered Oct 12 '22 23:10

Sam Roberts