Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:11:51+00:00 2026-06-05T23:11:51+00:00

Today I stumbled upon this thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/112560 The question is basically how to make

  • 0

Today I stumbled upon this thread:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/112560

The question is basically how to make Matlab read your startup.m file regardless of where
you start your matlab session.

One of the solutions offered was:

One solution would be to ask the system administrator to add a few lines
to “matlabrc.m” that adds some pre-determined folder in the user’s home
directory to the MATLAB path (say, ~/.matlabstart). Then each user can
have their own “startup.m” file inside this folder.

What I ended up doing in my system (OS X) was to add a startup.m file in:

/Applications/MATLAB_R2011a.app/toolbox/local/

In this startup.m file I added:

if exist([getenv('HOME') '/.matlabrc/startup.m'])
    run([getenv('HOME') '/.matlabrc/startup.m']);
end

That way users have the option of creating the hidden folder ~/.matlabrc and inside it they can put the file startup.m. In this startup file they can tell matlab what to execute whenever they start Matlab regardless of the directory where they started it. An example of what I added to my own personal startup.m file is

addpath(genpath('/Users/jmlopez/matlabcode/'))

Now I can add as many folders inside that directory and all of them will be added
to the path every time I start Matlab automatically without having to modify the path.

The question is: Did Matlab already provided a special file like the one I created or did I just go through all this trouble to accomplish what I wanted? If the answer is the second option I gave, then, why doesn’t Matlab provide this? It is such a pain in the ass to add directories to the Matlab path whenever you do not have admin permissions and I do not want to carry my startup.m file to every directory I go to. Can someone shed some light into this please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:11:52+00:00Added an answer on June 5, 2026 at 11:11 pm

    You can save the pathdef file (which stores all the paths you add) to a custom directory. The problem however is that when matlab starts, it doesn’t automatically know which custom directory you used in the previous session.

    But that’s where the MATLABPATH environment variable comes in. Because this allows to set the matlab starting path yourself. In linux this is simply done by setting this environment variable MATLABPATH before starting matlab (from a terminal / in your .bashrc / …)

    export MATLABPATH=$HOME/.matlab
    

    This way you can let all users have their own pathdef file, which solves the problem of having to add them manually at startup.

    EDIT

    I tested out if adding startup.m to that MATLABPATH directory worked, ie: does matlab run that startup file? … and it does. I think it doesn’t work for you, because there is another startup.m file in some other (higher priority) directory (probably matlabroot), so that gets precedence. My only startup file is in MATLABPATH, so there is only one choice.

    EDIT2

    Nope, I added startup to matlabroot directory, and still my own startup file in .matlab gets run. Are you sure you set the MATLABPATH correctly before you started matlab?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I stumbled upon a question here on Stack Overflow - How do I
I stumbled upon this oddity today while playing with some code to go down
I stumbled upon this piece of code today: CGRect rect = {{0,0},{w,h}}; Here, I
Hi all I stumbled upon this piece of code today and I am confused
This is a bit a silly question, but I stumbled upon this strange character
We stumbled upon an issue in our code today, and couldn't answer this Clojure
Today at work, I stumbled upon a problem that was driving me nuts. Basically
I Have stumbled across CNN's website today http://edition.cnn.com/TECH/ they seem to have several other
Today I stumbled upon the possibility to access a DOM element in Javascript simply
I stumbled across this C code today. Can anyone tell me what the 'where'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.