How to define a class in MATLAB that uses methods defined in separate files (in the @ -folder)?

I would like to define a class in one file and its methods in several other files.

Apparently, the way to do this is to create a subfolder named @<ClassName> in the class folder and put all the method files in the so-called "@ -folder".

However, as soon as I created the @ -folder, I am not sure what to add to the class definition file so that it knows about the methods in the @ -folder.

 classdef myClass properties myProperty = 0; end methods %# %# --- What goes here? --- %# end end 
+4
source share
1 answer

You declare a function signature without the function keyword and with a semicolon at the end.

 classdef myClass properties myProperty = 0; end methods retval = my_function ( arguments ); end end 

Then MATLAB will go look for a file called ../@MyClass/my_function.m .

+4
source

Source: https://habr.com/ru/post/1411215/


All Articles