llama.files.matlab module

FileHandlers that make calls to MATLAB in order to generate their data. You will need to specify the directory containing MATLAB functions to call with the environmental variable MATLABDIR.

class llama.files.matlab.MATLABCallingFileHandler

Bases: llama.filehandler.FileHandler

A class that is generated by calling a MATLAB function. The generator just calls the matlab function specified by the matlab_command property using MATLAB command-line options specified by matlab_options.

abstract property matlab_command

Return the command that MATLAB will eval in order to generate this file.

matlab_options = []
llama.files.matlab.matlab_eval(matcmd, cli_flags=None)

Run a command in a headless instance of MATLAB. By default, changes to the Neutrinos directory of the repo directory, which is where all LLAMA MATLAB code is currently stored. NOTE that your command can have multiple statements, but it CANNOT have newlines; it must have semicolons separating valid statements (See example below).

You can also provide a list of command line flags like “-nojvm” to modify MATLAB’s behavior. This implementation will be removed if we switch to MATLAB Engine, since MATLAB is not called through the command line interface when using the MATLAB Engine interface.

Examples

Print “foo” and “bar” on separate lines, checking first if MATLAB is installed: >>> try: … matpath = matlabpath() … matlab_eval(“disp(‘foo’);disp(‘bar’)”) … except OSError: … # put your cleanup code here … pass

llama.files.matlab.matlabpath()

Get a path to a matlab executable (if it exists). If something called matlab is in your $PATH, this will be used. Otherwise, if you have specified $MATLAB_EXECUTABLE_PATH as an environmental variable, that path will be used. If both of these checks fail, the most recent version of MATLAB matching the pattern /Applications/MATLAB_R20*.app/bin/matlab will be used (only applicable on MacOS).