Code covered by the BSD License  

Highlights from
matproj

4.66667
4.7 | 3 ratings Rate this file 40 Downloads (last 30 days) File Size: 8.62 KB File ID: #41505
image thumbnail

matproj

by

Kevin Bartlett (view profile)

 

26 Apr 2013 (Updated )

Saves and loads Matlab "projects" in editor (currently-open files, working directory, search path).

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

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.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
28 Jan 2015 Kevin Bartlett

Kevin Bartlett (view profile)

@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.

Comment only
28 Jan 2015 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.

22 Jan 2015 Kevin Bartlett

Kevin Bartlett (view profile)

@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"?

Comment only
22 Jan 2015 JAY R

JAY R (view profile)

not working

Comment only
02 Oct 2014 Kevin Bartlett

Kevin Bartlett (view profile)

@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.

Comment only
01 Oct 2014 Yoav L

Yoav L (view profile)

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?

30 Jul 2013 Kevin Bartlett

Kevin Bartlett (view profile)

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.

Comment only
29 Jul 2013 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.

Updates
28 Jan 2015

Update fixes bug pointed out by David Brown--unmodified "untitled" files no longer cause matproj loading to fail.

Contact us