In order to use the tsdf library in Matlab, you need to install the tsdf
library in Python and then link it to MatLab. The following steps will guide you through the installation process.
Ensure you have MATLAB version R2021b or higher.
Check your MATLAB version by running ver
in MATLAB.
(optional) Visit MATLAB's Python Support Page to verify compatible Python versions for your MATLAB version.
Download and install a Python version >= 3.9.
In MATLAB, execute the following code, replacing 'enter_path_to_python_executable_here'
with the path to your python.exe
file:
pyenv('Version','enter_path_to_python_executable_here')
For example:
pyenv('Version','C:\Users\username\AppData\Local\Programs\Python\Python39\python.exe')
Confirm the setup by running:
pe = pyenv;
pe.Version
You should receive confirmation messages indicating the Python version linked to MATLAB.
If you had a previous Python version installed, ensure the required libraries are installed in your new Python 3.9 environment (linked to MATLAB).
Open the Windows command terminal and navigate to the Python 3.9 installation folder:
cd C:\Users\username\AppData\Local\Programs\Python\Python39
Launch the Python terminal:
python
Install necessary libraries (e.g., NumPy and SciPy) by entering:
import sys
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install','tsdf'])
Clone this repository to your local machine.
Open MATLAB and add the cloned folder to your MATLAB path.
addpath('full_path_to_cloned_folder')
We aim to use this tutorial to integrate tsdf into the matlab code:
https://aleksandarhaber.com/tutorial-on-how-to-execute-python-code-directly-matlab/
The tutorial covers how to import numpy arrays from python code export them from Matlab double. A discussion on the topic is available here:
https://www.mathworks.com/matlabcentral/answers/157347-convert-python-numpy-array-to-double
Another article that is needed is on how to import python dict into Matlab and how to export them from Matlab struct.
https://nl.mathworks.com/help/matlab/matlab_external/python-dict-variables.html