7

I am a bit surprised, but I can't run matlab by the terminal of my Mac. I am trying the command

/Applications/MATLAB_R2015b.app/bin/matlab

but I get the error

-bash: matlab: command not found

Listing the contenents of the folder /Applications/MATLAB_R2015b.app/bin/ I can see the word matlab which is supposed to be the executable. I don't know what's happening.

10
  • 1
    What happens when you try cd /Applications/MATLAB_R2015b.app/bin/ followed by ./matlab? Commented Jul 26, 2017 at 3:31
  • 1
    @informaton It works! Thank you very much! Do you know why this strange behavior? Commented Jul 26, 2017 at 3:37
  • 1
    That doesn't make sense. You should be able to start it with the full path. However, you can make this simpler by adding /Applications/MATLAB_R2015b.app/bin to your system path in your .bash_profile so all you have to do is type in matlab instead and you can start MATLAB regardless of whatever directory you're in. Commented Jul 26, 2017 at 3:39
  • 1
    Neither do I. Even the MATLAB documentation says you can specify the full path to the executable and you should be able to run it: mathworks.com/help/matlab/ref/matlabmac.html Commented Jul 26, 2017 at 3:44
  • 1
    @Alessandro Excellent! I'll post it as an answer then. Sorry I can't be more help on the reason for the issue. I'm guessing there is something else going on with your profile as raryeng is pointing to. You can try running cat ~/.bash_profile or cat ~/.bashrc to double check that there is not another matlab reference somewhere, for starters. Commented Jul 26, 2017 at 3:58

3 Answers 3

8

Try

cd /Applications/MATLAB_R2015b.app/bin/

and then

./matlab

If that, hopefully, works, then you may have a path or environment issue with your O/S which is preventing your call to /Applications/MATLAB_R2015b.app/bin/matlab from working.

Sign up to request clarification or add additional context in comments.

Comments

6

add the installation directory to the PATH environment, for example:

export PATH=/Applications/MATLAB_R2017b.app/bin/:$PATH

then launch Matlab with

matlab

in your terminal

2 Comments

Why do you need the :$PATH. I tried echoing $PATH, and I get a string of other "bin". For instance, /Users/XXXX/google-cloud-sdk/bin. Why would I need to append that to MATLAB's bin? Thankss!!
this syntax concatenates the new path to existing paths and why you would want to do that depends on how you want to maintain your path variable. I like to not overwrite it since other applications access this variable.
0

It works fine, however, if you used the default folder it would be something like export PATH=/usr/local/MATLAB/R2021b/bin/:$PATH Additionally, remember about activating matlab before via running the activate_matlab.sh script located in the installation folder

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.