What do you have in your startup.m

4 views (last 30 days)
Brandon
Brandon on 13 Mar 2015
Answered: Image Analyst on 14 Mar 2015
What do you have in your startup.m file? Does anyone have a creative use (e.g. reminder of significant others birthday)?

Answers (3)

Image Analyst
Image Analyst on 14 Mar 2015
I set my desired starting current folder, like the other people do. I also call addpath(genpath()) to add some utilities folders to my search path.
I also have "isdeployed" in there to set the current folder to different folders depending on whether it's my development computer, or a target computer for a deployed app. Your startup.m gets run on the target computer when you deploy a compiled app - something that perhaps some people don't know - so you want to make sure you don't try to set the folder to some folder that the target machine won't have.
I also call filebrowser
filebrowser; % Won't work with compiled programs.
within the ~isdeployed if block because I want to see the current folder when MATLAB starts up.
The final line of my startup.m file says
fprintf(1, 'Done running startup.m.\n');
so I know when MATLAB is done initializing and I can begin to work.

Star Strider
Star Strider on 14 Mar 2015
I have calendar reminders and ‘Days until ...’ in my startup.m, but most important to me is that it keeps my user directories updated:
pathmat = path;
My_Path = userpath;
My_Dir = My_Path(1:strfind(My_Path,';')-1);
My_Work_Dir = genpath(My_Dir);
addpath(My_Work_Dir, '-end');
I keep all my user files and subdirectories in a directory called ‘My_Files’. This code updates any changes I might have made, and includes all new directories. It makes it easy to add new directories for FEX downloads, and since it updates them on every re-launch, they are always available. I’ve had to update it in the 15 years I've used it, to incorporate changes in the relevant MATLAB directory functions. It works with R2014 and R2015a.

Jan
Jan on 14 Mar 2015
In my startup.m the default fonts are set, date and computer name are displayed to keep the overview on remote desktop activities and the title of the command window is set to the Matlab release number and bit version like "2011b/64", because I have to run tests with different Matlab versions and a fast identification is useful. Finally a tool is called to activate a set of folders for the current project.

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!