diff --git a/interfaces/matlab/testpath.m b/interfaces/matlab/testpath.m index 7e773dacf..7b90a512b 100644 --- a/interfaces/matlab/testpath.m +++ b/interfaces/matlab/testpath.m @@ -1,8 +1,15 @@ -% get list of directories -% dirs = strread(path, '%s', 'delimiter', pathsep); +% testpath.m +% Set up environment for testing the Cantera Matlab interface +% from within the Cantera source tree. Run this file from the +% root of the Cantera source tree, e.g.: +% +% cd ~/src/cantera +% run interfaces/matlab/testpath.m + +% get the list of directories on the Matlab path dirs = regexp(path, ['([^' pathsep ']*)'], 'match'); -% if 'cantera' is already in the path, we want to remove it +% if 'cantera' is already in the path, remove it for i = 1:length(dirs) if strfind(dirs{i}, 'Cantera') rmpath(dirs{i}); @@ -13,8 +20,21 @@ for i = 1:length(dirs) end end -path(path, [pwd filesep 'toolbox']); -path(path, [pwd filesep 'toolbox' filesep '1D']); +% Add the Cantera toolbox to the Matlab path +path(path, fullfile(pwd, 'toolbox')); +path(path, fullfile(pwd, 'toolbox', '1D')); + +cantera_root = fullfile(pwd, '..', '..'); + +% Copy the Cantera shared library from the build directory if necessary +if strcmp(getenv('OS'), 'Windows_NT') + copyfile(fullfile(cantera_root, 'build', 'lib', 'cantera_shared.dll'), ... + fullfile(pwd, 'toolbox')) +end % Set path to Python module -%setenv('PYTHONPATH', [pwd filesep 'interfaces' filesep 'python']) +setenv('PYTHONPATH', fullfile(cantera_root, 'interfaces', 'python')) +setenv('CANTERA_DATA', fullfile(cantera_root, 'data', 'inputs')) + +% A simple test to make sure that the ctmethods.mex file is present and working +f = Func('polynomial', 3, [1,2,3,4])