MATLAB Startup

See also MATLAB startup - Sydney.

When MATLAB starts, it will look for a file "startup.m" and run it. This file runs a few commands. For example, it might move to the SPM folder, add that folder to the path, and start SPM:

>> cd c:\matlab\spm12
>> addpath c:\matlab\spm12
>> spm fmri

Example:

Location of startup file

To see the location of the startup file, if it exists:

There are two locations it looks for this file: in current versions of MATLAB, it will look in C:\Users\[...]\Documents\MATLAB. This is the preferred place to have the startup file. However, it needs to be copied for every user.

Option for multi-user computer: Another location is in the MATLAB program files folder C:\Program FIles\MATLAB\[release]\toolbox\local. This does not need to be copied for each user, but it does need to be copied each time MATLAB is updated.

See also MATLAB help.

Editing the startup file

To edit the startup file, open it in the MATLAB editor:

If you are having problems at the start, like this

you will need to edit the file.

Troubleshooting

Example 1

The option was to run SPM12, but the error is "Undefined function 'spm'. This means that MATLAB did not see the SPM12 folder. This is mostly likely because the startup file goes to an incorrect location. For example, if the startup file includes

cd c:\matlab\spm12

but M the matlab files are on D:\matlab, then the above error would occur.