0

I'm currently using a MATLAB software suite which includes a function called "Swap". Running this code on my personal machine runs just fine, but when attempting to run on a Linux server, it seems to be trying to use the built-in "Swap" function on the Linux terminal.

Is there some way that I can force the terminal to ignore this built-in Swap and simply call the "Swap" function which is part of the MATLAB suite?

Thanks!

Vincent Russo
  • 1,087
  • 3
  • 20
  • 33
  • 1
    `built-in "Swap" function on the Linux terminal`? I am confused by that statement. – Divakar Mar 31 '14 at 16:50
  • How do you call your functions? Are you running Matlab? If so, how can the system command interfere? Matlab will try to access internal functions or give you an error. It does not use "outside" functions. – Schorsch Mar 31 '14 at 17:16

1 Answers1

1

Assumptions: When you said built-in "Swap" function on the Linux terminal, I am assuming you are talking about running MATLAB on the linux terminal itself. I am also assuming that the built-in swap command is something from the MATLAB platform and not the linux environment and this answer is based on these assumptions.

In a general case, when you would like to add a function file whose name is identical to an already exisiting function, you have to move the path of the function file to be added to somewhere above the path of the existing function file in the list of MATLAB search paths. The way it works is that when you mention the use of a function, MATLAB starts looking for a match from the top until the bottom of the list.

One can view the MATLAB search paths by running -

path

So, to answer your question, just add the path of the suite to the top of MATLAB search paths by using addpath -

addpath(PATH_TO_SUITE);

If PATH_TO_SUITE has subdirectories, one of which has the swap function file, use genpath along with addpath -

addpath(genpath(PATH_TO_SUITE));

This could be interesting too for you to follow - Access m-files in a subfolder without permanently adding it to the path.

Community
  • 1
  • 1
Divakar
  • 218,885
  • 19
  • 262
  • 358
  • Thanks, that was exactly the problem, I was adding one of the other suites with a conflicting name prior to adding the one I wanted to use. This solved the problem, thanks again! – Vincent Russo Mar 31 '14 at 18:02