MATLAB installation

Since 2019, MATLAB allows you to import Python packages into its environment. Codac offers a Python package dedicated to MATLAB, with the necessary adaptations to run in this environment (for example: indices starting at 1, alternatives to unsupported & and | operations, etc.). This Python package dedicated to MATLAB is called codac4matlab. See the related PyPI page.

  1. Dependencies: Ensure you have MATLAB R2019b or later.

  2. Python integration: Follow the instructions here to set up Python integration.

  3. Install the Python package:

    pip install codac4matlab --pre
    # Option --pre has to be set because Codac v2 is only available in pre-release
    

Once Codac is installed, you can use it in your MATLAB scripts using the following import command:

import py.codac4matlab.*

% Your code...

Potential problem with VIBes

One of the graphical outputs supported in Codac is the VIBes viewer. VIBes uses a client/server architecture and reads its configuration from the .vibes.json file located in your home directory (typically $HOME). This file is automatically generated.

If you launch MATLAB with sudo, the HOME variable points to /root, and VIBes will not find the .vibes.json file, causing the display to fail.

A solution is to avoid using sudo. If required, run MATLAB with the correct HOME:

sudo HOME=/home/your_username matlab