As mentioned here, the add on library interface functions as a server client model. You send a command using the "sendCommand" function from MATLAB and provide a commandID. This is sent to the Arduino which reads the commandID, runs the appropriate function from the C++ file and then uses the "sendResponseMsg" command to return any data that needs to be sent back.
The basic interface for these functionalities are provided in the arduinoio.LibraryBase class in MATLAB and librarybase.h in C++. In your add on you will build on top of these so that you can run your commands.
If we consider the simple HelloWorld example provided over here First, we create a folder structure as mentioned in the link.
Second inside the C++ code we include LibraryBase.h and any other libraries used by our code. Then we create a class that inherits from the base class and inside the constructor we provide a name for the library and we register it so that the Arduino server knows that such a library exists.
After this, inside the command handler, we use switch case which will decide what piece of code will run when "sendCommand" sends a given commandID. So for each commandID you call the appropriate functions from your file and do whatever you want (get data from sensor, turn on a LED, etc.) This will complete the Arduino part of the add on.
After this, we set up the MATLAB interface that will provide the actual functions that we will call from MATLAB, to run our code on the Arduino.
To do this we create a class that inherits from the "arduinoio.LibraryBase" class. Inside it we define the commandIDs for each command, define any constants and specify the location of the header files.
The methods of this class will send a commandID to the arduino server, which in turn will run the appropriate function on the Arduino.
In the HelloWorld example, the read() function in HelloWorld class sends commandID 0x01 to the server. The server checks the commandID (inside the command handler) and then sends "Hello World" back to the read() function which in turn prints it.
The basic architecture for your code will be the same just the functions in the MATLAB Class will correspond to the functions that you want to execute and you will have to add the corresponding code inside the command handler.
Hope this helps.