0

I've been trying to work on opening/executing MATLAB from bash (I'm using Terminal, specifically). However, despite numerous attempts at troubleshooting, I have been unable to do it.

Running the "matlab" command gives me the error:

-bash: matlab: command not found

A cursory Google search suggested it could be an issue of my local bin, but my bin looks like:

/usr/local/bin:
  total used in directory 16 available 208047788
  drwxr-xr-x  4 alifarhat  wheel  136 Jul 22 11:30 .
  drwxr-xr-x  3 alifarhat  wheel  102 Jan 22 01:56 ..
  lrwxr-xr-x  1 alifarhat  wheel   29 Jul 22 11:30 matlab -> /usr/local/matlab6/bin/matlab
  lrwxr-xr-x  1 alifarhat  wheel   26 Jul 22 11:30 mex -> /usr/local/matlab6/bin/mex

Which seems to indicate that matlab is talking to the bin.

If it helps, when I cd into /usr/local and then ls, the only directory/item in there at all is "bin". Could this have something to do with it? How can I fix it if it does?

Shai
  • 111,146
  • 38
  • 238
  • 371

2 Answers2

1

It seems like PATH issues. Is /usr/local/bin in your $PATH?
Try

 ~$ echo $PATH

What do you see?

If /usr/local/bin is not part of your $PATH you can add it:

 ~$ export PATH=/usr/local/bin:$PATH

Then try and run matlab from shell

EDIT:
Based on these comments it seems like matlab executable is not located at /usr/local/matlab6/bin. Therefore, you can either

  1. Add /Applications/MATLAB_R2014a.app/bin/ to path:

    ~$ export PATH=/Applications/MATLAB_R2014a.app/bin:$PATH

or

  1. Replace the broken symbolic links in /usr/local/bin (you might need root privileges for this). See this thread for more details.
Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371
0

Once you are in the correct directory, you should execute the command:

    ./matlab

instead of just typing matlab.

jfish003
  • 1,232
  • 8
  • 12
  • There's an issue with finding "the correct directory" as you can see from [these comments](http://stackoverflow.com/questions/31571212/executing-matlab-from-bash/31571312?noredirect=1#comment51097544_31571312). – Shai Jul 22 '15 at 18:44