Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

matlab.setup_matlab

matlab.setup_matlab

Functions

NameDescription
add_matlablatest_pathAdd the ‘matlablatest’ path to the MATLAB environment using manage_paths.
connect_to_matlabConnect to an existing shared MATLAB session, or start a new one.
setup_util_pathAdd the MATLAB utils path to the MATLAB engine’s path, if not already present.

add_matlablatest_path

matlab.setup_matlab.add_matlablatest_path(eng)

Add the ‘matlablatest’ path to the MATLAB environment using manage_paths.

Parameters

NameTypeDescriptionDefault
engmatlab.engine.MatlabEngineMATLAB engine instance.required

Raises

NameTypeDescription
ValueErrorIf the MATLAB engine instance is invalid, or no ‘matlabfiles’ paths are found after adding ‘matlablatest’.
RuntimeErrorIf the ‘manage_paths’ function is not available in MATLAB.

connect_to_matlab

matlab.setup_matlab.connect_to_matlab()

Connect to an existing shared MATLAB session, or start a new one.

Make sure to only call this function once per session — a second call to connect to the same shared engine raises an EngineError.

Returns

NameTypeDescription
matlab.engine.MatlabEngineThe connected (or newly started) MATLAB engine instance.

setup_util_path

matlab.setup_matlab.setup_util_path(
    eng,
    matlab_utils_path=os.environ.get('MATLAB_UTILS'),
)

Add the MATLAB utils path to the MATLAB engine’s path, if not already present.

Parameters

NameTypeDescriptionDefault
engmatlab.engine.MatlabEngineMATLAB engine instance.required
matlab_utils_pathstr | NonePath to the MATLAB utils folder. Defaults to the MATLAB_UTILS environment variable.os.environ.get('MATLAB_UTILS')