Clear Filters
Clear Filters

How can I make Cantera functions available in Matlab or link them?

33 views (last 30 days)
I am working with a Matlab script that calls for Cantera functions such as "IdealGasMix('gri30.cti','gri30_mix')".
Originally the script was written to be used with Cantera-1.8.0., whereas I am using Cantera-2.2.1. Nevertheless I have tried using different Cantera functions such as addDirectory() or importPhase('gri30.cti','gri30_mix'), but I always get the message, that the function can not be found. I was told that if Matlab is installed before Cantera, all necessary packages from Cantera will automatically be included...
What do I need to do to make Matlab link to those packages? Do I need to install additional tools? How do I include those?
Any suggestions may be of help, so please feel free to answer, if you have any ideas?
Thanks so much!
Cheers, Stefanie
BTW I am working with Matlab through a license provided by my school and therefore I am usually connected to it via VPN. Not sure if that makes a difference...
  3 Comments
Stefanie De Graaf
Stefanie De Graaf on 11 Jan 2018
Hi Walter! Yes I did follow these instructions. I am on a Ubuntu machine though.
Any suggestions what I need to do to load the cantera functionality?
The error I am getting in Matlab is:
Undefined function or variable 'importPhase'.
Error in boundarypoints (line 4) gas = importPhase('gri30.cti','gri30_mix');
Stefanie
Shubham Pandit
Shubham Pandit on 30 Nov 2020
Hey Stefanie
Did you get answer for your quesry? I am facing the same problome. I don't even know how to install cantera in Ubuntu 18.04.5 LTS such that it can work in MATLAB.
Any help will be greatly appreciated! Thanks!
Shubham Pandit

Sign in to comment.

Answers (1)

David
David on 27 Aug 2021
I think this is really a Cantera question. There are a couple of steps where the installation can go wrong. See the Cantera installation instructions, including how to make it talk to MATLAB, here: https://cantera.org/install/index.html. For a Windows operating system, there are more details on interfacing to MATLAB here: https://cantera.org/install/windows-install.html. Note that you have to install Python, Cantera, and MATLAB.
To check if everything is talking, follow the advice at the bottom of the installation page. That is, try running (in MATLAB)
h2o = Solution('liquidvapor.yaml','water')
This checks that MATLAB can find the Solution function and the requested data file. Some functions, including importPhase, are now deprecated. This caught me for quite some time, and motivated me to provide answers to these questions. See more discussion on importPhase here: https://www.mathworks.com/matlabcentral/answers/574450-matlab-is-showing-the-following-error-unrecognized-function-or-variable-importphase

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!