Link Matlab and Cantera

101 ビュー (過去 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 Center および File ExchangeIntroduction 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