Link Matlab and Cantera

조회 수: 98 (최근 30일)
Léo
Léo 2025년 4월 18일
답변: Léo 2025년 4월 24일
Hello everyone,
I am trying to use Cantera with Matlab. I am using matlab v2020b, Visual Studio 2022, python 3.13 and use Cantera v3.0 as v3.1 seems not to be compatible with the Matlab interface, as mentioned on their website. I tried several solutions, but I am still stuck, and the documentation for v3.0 is no longer available: https://cantera.org/install/index.html (not found).
  1. First, I tried using conda with the following command:
conda create --name ct-env --channel cantera cantera cantera-matlab
However, after setting the ctpath.m, I encountered the following error:
gas = Solution('gri30.xml') Invalid MEX-file 'C:\Users\*\*.conda\envs\ct-env\share\cantera\matlab\toolbox\ctmethods.mexw64': The specified procedure could not be found.
The MEX file is present but seems to not be working.
2. I also tried cloning the Git repository, followed by scons build and installation.
This gave me the Matlab experimental folder. I followed the README procedure and changed the ctRoot.m to put the path to my conda environment, but I encountered this error:
Error using loadlibrary Could not find file C:\Users\*\*.conda\envs\ct-env2\include\cantera\clib\ctmatlab.h.
After some research, I found that maybe my python version is not compatible with my matlab version, refer https://fr.mathworks.com/support/requirements/python-compatibility.html & https://groups.google.com/g/cantera-users/c/KVK3EBwOVfw I tried changing to python 3.8 but same error appears. I also found that an .msi installer is also available, and I will try this option last, but I would prefer to stick with conda if possible. If anyone knows how to make it work, I would really appreciate your help.
Lastly, I tried using the Python extension, and it works: such as py.cantera.Solution('gri30.yaml') cmd. However, I do not want to be dependent on Python, as I may need to compile my code using Simulink/Matlab Coder.
Have a nice day!

채택된 답변

Léo
Léo 2025년 4월 24일
[UPDATE]
The easiest method is to download the .msi and install it. Everything is now running smoothly.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by