Executing MATLAB from Bash

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?

Upvotes: 0

Views: 589

Answers (2)

jfish003
jfish003

Reputation: 1332

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

    ./matlab

instead of just typing matlab.

Upvotes: 0

Shai
Shai

Reputation: 114976

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.

Upvotes: 1

Related Questions