MATLAB: How to Create Libraries in Matlab

m-fileMATLABtoolbox function

OK, I switch gears often between C, Matlab, and Python-so I am really a beginner in the Matlab world. Is there any way, in pure Matlab to create the equivalent of a library? I have several closely related functions that control a piece of hardware. The individual functions are relatively simple, so it seems asinine to have to put each one in a separate m-file. Is there a way I can group them all together? I guess this would be the equivalent of creating a toolbox, but what reading I've done seems to recommend against this approach. In the separate file sceneraio–does Matlab cache the functions in any way, or does the file have to be read from disk every time I call the function? It would seem this would introduce lots of latency.

Best Answer

The simplest approach would be to put the functions in their own folder and add that folder to the MATLAB path. Whether it's asinine to put each function in a separate file may be a matter of taste. If they are in separate files, you can see them all at a glance, and you can create a contents report, which you can then organize in any way that seems useful.