2

In one of my projects, I have a Matlab function called eom.m. When I try to call it, I get errors. I have realised this is because Matlab calls a simulink file, eom.slx, instead, which is in one of the toolboxes.

I would prefer not to rename the function, so I was wondering how I could change the order in the Matlab path so that the folder I call Matlab from always has top priority. That is to say how I can ensure that the files in my current working directory are always those that are called in fact.

Thank you for the help!

Enrico Anderlini
  • 447
  • 6
  • 21

1 Answers1

3

You can do it programmatically using addpath with the '-begin' option.

  1. You can use command syntax:

    addpath c:/path/you/want -begin
    

    Enclose with quotes if the path contains spaces:

    addpath 'c:/path /you/ want' -begin
    
  2. Alternatively, you can use function syntax:

    addpath('c:/path/you/want', '-begin')
    

    This allows having the path stored in a variable:

    p = 'c:/path/you/want';
    addpath(p, '-begin')
    
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147