Start a MATLAB project


You are using Python?


MATLAB/Octave support is preliminary, limited tests have been made for now. See this example.
Codac is ready to be used if you have at least MATLAB R2019b, a supported version of Python and installed Codac Python package.

MATLAB specificities

Integers in function calls from the Codac library should be cast to int32, e.g. 4 would be int32(4) (however do not change those that are in strings), otherwise remember that all numbers are double by default in MATLAB.
The operator [index] for a Codac object should be replaced with .getitem(int32(index)) when getting its value while it should be replaced with .setitem(int32(index)) when setting its value (please note that indices of Codac objects start at 0 contrary to typical MATLAB objects such as MATLAB arrays or cell arrays).
The operators/functions x&y (intersection) for a Codac object should be replaced with x.inter(y), x|y (union) with x.union(y), x&=y (intersection and update of x) with x.inter_self(y), x|=y (union and update of x) with x.union_self(y), x**y (power) with x.pow(y), abs(x) (absolute) with x.abs().
Python lists of objects should be converted to MATLAB cell arrays.
Also, when a Codac function needs a py.list or Vector parameter, the corresponding MATLAB cell array should be given as py.list(…) (however when the Codac function do not need a py.list or Vector parameter but just an element of a MATLAB cell array, do not convert with py.list(…) and be sure to get the cell array element with {} operator).
Be sure that Python multiline strings are correctly converted to multiline MATLAB strings between . Remember that multiline statements in MATLAB need before next line.
Please also convert Python for loops to typical MATLAB for loops, same for if-else, += statements.

Automating Python to MATLAB conversions

Bing Chat with GPT-4 in Precise conversation style has been used successfully to help convert Python examples to MATLAB, using the description above and by providing and the corresponding a01_getting_started.m as example (about 80% of the code for 03_static_rangebearing.m and 05_dyn_rangebearing.m was correctly converted this way).
import py.codac.*

x = Tube(Interval(0,10), 0.01, TFunction("cos(t)+abs(t-5)*[-0.1,0.1]"));

fig = VIBesFigTube("My first tube");
fig.add_tube(x, "x");;
This script will create a simple tube and display it.

In order to visualize the tube, you need to launch before the VIBes viewer independently.

If everything is well installed on your computer, you should see the following window appear:



Octave support has been only briefly tested on Ubuntu 22.04 for now. Pythonic can be used to be able to call Python code from Octave. Some known necessary adaptations (see also are:

  • Missing import command. can be loaded in Octave as a workaround. To always load it, try to add its content to ~/.octaverc (e.g. with cat import.m>>~/.octaverc).

  • In at least Octave v6.4.0 and below, operators such as +, -, *, /, ==, !=, etc. are not overloaded (note that these operators are supported by MATLAB, but some others might not be supported by MATLAB either, see the bottom of The internal methods __add__(), __sub__(), __neg__(), __mul__(), __truediv__(), __eq__(), __ne__(), etc. can be used instead. A modified version of Pythonic is currently being developed to support these operators (see and can be installed as follows:

    sudo apt install octave liboctave-dev libpython3-dev build-essential make git
    git clone
    cd octave-pythonic
    git fetch operators
    git checkout -b octave-pythonic-operators FETCH_HEAD
    make check
    octave --path $PWD/inst --path $PWD/src

    Then in Octave:

    pkg install .

Then, Codac should be ready to be used in Octave as in MATLAB.