1

So I have the following problem: I have a folder at a location known from a config.py file, in my case externals/bct. Now this needs to be added to matlab's path. Now I've searched for some examples to edit matlab path but from what I can see let's say here: matlab path the changes are done from matlab. My question would then be: is there any way I could change the matlab path from python?

Best regards, Bogdan

1
  • I'm fuzzy on your use case. Are you calling matlab at runtime from python? Are you wanting to run a python script to set up a matlab script that runs? Why can't you just write a .m file from python at a well known place and point matlab at it? Commented Aug 10, 2011 at 13:01

2 Answers 2

1

Thanks for the inputs. The project already has an adapter that allows runnig matlab code from python using from scipy.io import loadmat, savemat. The problem was that we are using BCT and that need to be added to matlab path dinamically at startup. The solution that worked for me was to use the method already defined to execute matlab code and just send at startup:

addpath(PATH_TO_BCT); savepath; 
Sign up to request clarification or add additional context in comments.

Comments

0

Your source says:

path displays the MATLAB search path, which is stored in pathdef.m

I believe your best bet is to find this pathdef.m file in the Matlab install folder, then open and change it from python.

On my Windows Machine with Matlab 2008a, it's in C:\MATLAB\R2008a\toolbox\local\pathdef.m. There are two emptied-out versions of the same file at \local\ja and \local\template, but that first one seems to be the one that counts.

There's a big warning in it saying not to edit, but it's plain text Matlab language, really easy to reverse-engineer, you should be fine. Just don't forget the semicolon at the end of each path string (unless they changed synthax in the new version you might have... just take a look at your file.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.