.. _sec-install-matlab:
MATLAB installation
===================
Main authors: `Fabrice Le Bars `_, `Simon Rohou `_
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**:
.. code-block:: bash
pip install codac4matlab
Once Codac is installed, you can use it in your MATLAB scripts using the following import command:
.. tabs::
.. code-tab:: matlab
import py.codac4matlab.*
% Your code...
.. py.importlib.import_module('codac')
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``:
.. code::
sudo HOME=/home/your_username matlab