File Exchange

image thumbnail


version 1.5 (13 KB) by Kevin Bartlett
Saves and loads Matlab "projects" in editor (currently-open files, working directory, search path).


Updated 17 May 2016

View Version History

View License

This GUI-driven tool makes it easier to switch from task to task by allowing you to save the current state of your Matlab Editor session as a "project", for later re-loading.
A Matlab "project" consists of the m-files that are currently open in the Matlab Editor. Loading a project
returns the Matlab Editor to the state it was in when the project was saved, with the same m-files open to the same lines, the working directory set to that of the loaded project and the Matlab search path set back to its saved value.

Cite As

Kevin Bartlett (2021). matproj(varargin) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (36)

Kevin Bartlett

Hi, @Dmitry,
I would like to help you, but I don't use live scripts, so I wouldn't know how to start. You're certainly welcome to modify my code if you feel up to it.
Cheers, Kevin

dmitry luchinskii

Thank you very much for the nice and very helpful function. It saves a lot of time!
Would it be possible t extend this function to include live scripts into the project?
Thank you,

John Hargrove

waited for years for Mathworks to produce something like this. Wish I had found it earlier

Justin A.

Miten Patel

Fantastic utility - can't imagine not having it ! Thanks

Maciej Wielgo

Alison Macdonald

This is unbelievably helpful. What a time saver! I wish I had found it when you first posted it. Thank you.

mojtaba taheri

Thank You!



Patrick Vacek

Kevin Bartlett

@Erik Gudmundson--A good suggestion. I suspect it is possible, but I don't know how to go about it, so it would probably take considerable work to implement. I will put it on my list of possible improvements.

Erik Gudmundson

Thanks a lot! As I tend to work on several projects at the same time, your piece of code is really helpful!

However, I tend to split my editor window into several parts (the amount depends on the screen size). Is there any chance to reopen the files in the same part of the split editor window?


Very useful, thank you!

Kevin Bartlett

@Roger--I should add that the best way to send me the output from the "path" command would be to save it as a variable in a .mat file:
myPath = path;

Kevin Bartlett

@Roger. Thanks very much for the feedback. I would like to fix this problem, if I can, but it is difficult to debug remotely. Please send me the matproj.mat file you are loading, plus the output of the "path" command (executed BEFORE loading the matproj.mat file). My address is

Roger Benton

Have upgraded Matlab to 2016a and down loaded the latest version of matproj but I hit an issue with the install directory for matproj. This is now 'matproj(varargin/code' rather than 'matproj/code' in the add-ons directory. When restoring a project saved in 2015b there are paths pointing to the old matproj directory causing an error. I have a crude work round by just searching and replacing matproj/code by matproj(varargin)/code in 'pathStr' just before line '291 matprojData.path = pathStr;'.
Regards Roger

Kevin Bartlett

@Zhaoyi and @John Thompson--I have submitted a bug fix to (hopefully) solve your problem. Have not been able to test the bugfix on a Windows machine, but it should work. Please let me know if you continue to have problems.

Kevin Bartlett

@Zhaoyi and @John Thompson--Correction: please email me your matproj.mat file and the output of the "path" command.

Kevin Bartlett

@Zhaoyi and @John Thompson--I'm working with an older Matlab version, so I can't duplicate your error. Please email me your matproj.m file and the output of the "path" command, and I should be able to find a fix.

John Thompson


Long time fan of matproj. Recently, downloaded for use on a new computer with install of 2015b and I'm getting the same error as Zhaoyi (11-04-2016). It looks like the knownBuiltInName is not found in the savedPaths cell array, and thus ind is filled with zeros, ultimately leaving knownBuiltInPath empty. Thoughts on a fix?


Really appreciate your work.

But when I run it on my MATLAB2014b, it shows:
Too many outputs requested. Most likely cause is missing [] around left hand side that has a comma separated list expansion.

Error in matproj (line 229)
knownBuiltInPath = knownBuiltInPath{:};

Is it a problem of my MALTAB or the version problem?

Thank you very much!


Kevin Bartlett

@Roger--The error you were getting was caused by matproj.m trying to set the path to the path for your previous Matlab version (e.g., "/Applications/" instead of "/Applications/").

I've added some code that should repair the path in the event of a Matlab upgrade (note that this was an improvement I'd been thinking of doing for some time; see the July 29, 2014 comment by per Isakson, below).

Let me know if this fails to work for you.

Roger Benton

Have sent you a message as the output was rather long. I found the problem only occurs when loading a project saved under 2015a into 2015b. Once saved under 2015b then it seems ok so far.

Kevin Bartlett

@Roger Benton--I don't have access to 2015b. Please edit matproj.m and add a debugging line just above where the error occurs (210). The code should look like this:
if isfield(matprojData,'path')

Post the results of the disp() command, and I'll see if I can make some sense of it.

Roger Benton

Excellent tool but having issues with release 2015b with messages like this:

In path (line 33)
In matproj (line 210)
Warning: Function upper has the same name as a MATLAB builtin. We suggest you rename the
function to avoid a potential name conflict.

It produces lots of these messages with different functions after which Matlab does not function correctly and I have to do a forced quit.

Could be something I am doing but any help would be appreciated as it is an invaluable tool.

Abhinav Gaur

great tool works as described

Kevin Bartlett

@David Brown--Thanks for pointing that out (and for your kind words!). I've uploaded a version that should fix the problem caused by unmodified "untitled" m-files.

David Brown

First - thanks for a very useful tool. I was in the process of creating something similar when I ran across this which saved me some work.

I did run across one small bug. When I saved the project and I happened to have an "Untitled" file open matproj saved the project without a problem but when I tried to open the project again it failed to open because "Untitled" was saved without an absolute path. I think this occurred at line 160 of matproj.m. I was able to load the MAT file into the base workspace and repair it fairly easily. I'm currently using R2012a.

It should be a simple fix to the M file. I'll just have to remember not to have an Untitled file open when I save the project.

Again - very useful tool and something that I've wanted for a long time. If this isn't already a feature in a newer version of Matlab it should be considered.

Kevin Bartlett

@JAY R--Can you supply more information, please? What operating system? What version of Matlab? What steps do you follow and in what way does the program "not work"?


not working

Kevin Bartlett

@Yoav L--No "quick fix" for that. The save_matproj function saves matprojData.workingDir as "pwd"; even more complicated, each filename of the mfiles open in the editor is saved as a fully-qualified filename, so you'd have to deal with that issue, too.

One solution I can think of would be to add two additional input arguments: one would contain the portion of the absolute pathname that you want to ignore (e.g., '/home/kevin/myProjectsDir/'); the second would contain the string you'd want to replace that portion of the pathname with (e.g., '../../'). In the code, then, the substitution would change (for example) '/home/kevin/myProjectsDir/todaysProject/myNiceMfile.m' to '../../todaysProject/myNiceMfile.m'.

Another alternative would be to work on the level of the operating system. You could use symbolic links if you're running on a Unix/Mac system or the Microsoft equivalent, if such a thing exists in Windows.

Yoav L

Very useful submission!
I am trying to modify it a bit so it can handle relative paths, making it possible to switch projects on different computers from a shared folder (that might have a different absolute path). any suggestions for quick fixes?

Kevin Bartlett

That's a good suggestion, Per. I could presumably use matlabroot instead of the literal path for built-in files. I'll try to incorporate this idea into the code when I have more time.

per isakson

I often have many files open at the same time and it is very convenient to be able to switch between sets of files. matproj works well.

However, some days ago matproj caused me some trouble. This is what happened.

Background: I've used R2012a until recently. Matlab was first updated to R2012b, which I didn't use because of ribbon-phobia. Now, Matlab is updated to R2013a, which I use because some bugs are fixed.

Incident: Without too much thinking, I loaded an old "project" with matproj and I was instantly in trouble. The path to the R2013a installation was replaced by the path to R2012a. For me that was no big problem once I realized what had happened.

Proposal: Modify matproj so that it does not affect the path to Matlab proper.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!