Hello David,
I understand that you would like to be able to save the multiple sessions of MATLAB, and be able to choose which to open. Unfortunately, there is no officially supported way of doing this easily. There may be unofficial ways that MathWorks cannot recommend, so it may be worth searching around for how other people restore previous sessions of MATLAB.
There are, however, several supported ways of saving and loading individual elements of a session. You could create a custom finish.m that would ask you to which "project" you want to save your components, and then saves them. Then you could have a custom startup.m that would ask you which "project" to load, and then load the previously saved components. You can get a list of files that are open in the Editor using:
docArray = matlab.desktop.editor.getAll;
fNames = cell(1,length(docArray));
for fIdx = 1:length(docArray)
fNames{fIdx} = docArray(fIdx).Filename;
end
You can save this (along with other session stuff) in a MAT-file. When you next open MATLAB, you can load the MAT-file and open each document with:
for fIdx = 1:length(fNames)
matlab.desktop.editor.openDocument(fNames{fIdx});
end
You could even save the line the cursor was at, and use the openAndGoToLine function to move the cursor to that point again.
The Command History window is trickier. You can get the command history from your current session using the command:
historypath = com.mathworks.mlservices.MLCommandHistoryServices.getSessionHistory;
This has been documented, but I am not aware of any documented function that does the reverse (appending to or modifying the command history). The Workspace is the easiest, since you can just use the save command to throw all your variables into a MAT-file, and the load command to get them back again. You could also save all open figures to a "project"-specific folder, and then reopen them (using the dir command to find files in that folder). I hope this helps with maintaining your workflow.
-Cam