Menu

ApplicationDevelopmentCode

Volkmar Glauche

Application Code Organisation

The batch system requires a split of code into interface declaration, consistency checks and computation code. It is not possible to request some input, do a calculation and then ask for another input within the batch system. Of course, it is possible to have user interaction in computation code, but the main purpose of a batch system is to collect all necessary before doing all computations. The batch system provides some very powerful means to structure input and to describe and run batches.

There are a wide range of possible approaches to code organisation:

  1. One file per application: Everything (i.e. input description, virtual output description and computation code) can be kept in one single large .m file. However, this file will grow rapidly and there are no means to call computation code from outside the matlabbatch system. This approach is definitely not recommended.
  2. One file per module: Everything that belongs to one module will be in this file. Still, the computation function can only be called from inside matlabbatch.
  3. Two files per module: One file for input configuration and virtual output function, another file for the computation code. This is a good tradeoff between number of files, readability and usability. The computation code can be used standalone.
  4. Three files per module: input configuration, virtual output function and computation in separate .m files. This configuration is enforced if the application configuration is generated with the configuration editor?.

In cases 2-5, an additional "top-level" configuration file will be necessary to combine the modules into a single application configuration tree.

Requirements for Computation Code

The only restriction to the computation code is that this code has to be able to extract its inputs from an input struct/cell array and its return argument (if any) should be a struct array with any number of fields. This can be implemented straight in the computation code. If this is not feasible (because of e.g. code readability, compatibility issues or use of 3rd party software along with the application), then some translation code has to be written that disassembles the input structure, runs the computation and collects the output arguments. See here for details.

Re-Distribution of matlabbatch Code

To make use of the batch system, matlabbatch must be installed on the machine running the application. Since MATLAB does not offer software management, it will be usually necessary to include matlabbatch code somehow in the application. Matlabbatch will try its best to detect multiple instances of itself on the current MATLAB path to avoid version mismatches.

Multiple Applications

A configuration and batch management utility is available that allows to combine configurations of multiple applications in one configuration tree. This combination allows to run modules from different applications in one batch job. Even passing data between different applications is possible, provided data formats are compatible.


Related

Wiki: space.menu

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.