Save Open State in Editor???

31 visualizaciones (últimos 30 días)
dpb
dpb el 17 de En. de 2020
Comentada: dpb el 9 de Oct. de 2025 a las 18:35
Is there no preferences option to have editor reload previous state w/o having to open each and every file again? Very rude behavior...

Respuestas (1)

Steven Lord
Steven Lord el 17 de En. de 2020
In the Preferences for MATLAB, there's a section titled Editor/Debugger. One of the options that you can select (and I believe is selected by default) is "On restart reopen files from previous MATLAB session". However I believe under certain circumstances (like if MATLAB crashes) that may not always work.
Or do you mean you accidentally or intentionally closed a file (or all the files) and want to undo that action? I don't believe there is a way to undo that, but it seems like a reasonable enhancement request.
As a third option, if you want to be able to "remember" what files are opened, close some and/or open others, then restore the "remembered" set of files I think the projects functionality in MATLAB may be of interest to you. That functionality was introduced in release R2019a.
  8 comentarios
Mac
Mac el 9 de Oct. de 2025 a las 16:53
Would it also be possible to use the automatically saved list of open matlab files (for instance in Matlab2020a) to make a newer matlab version (for instance Matlab2024b) installed on a different computer (with the same file structure) open the same files?
(Or is there some other way to open a long-ish list of files (same file structure on computer) on another computer)
dpb
dpb el 9 de Oct. de 2025 a las 18:35
I do not know precisely where the list of open files is kept; somewhere in the preferences, probably, but I'd guess it wouldn't be directly portable to a new version, particularly from prior to R2024x to R2024x+.
The way to do it that would be portable would be to retrieve the open files via the MATLAB Editor API and then export those filenames to the new system as arguments to the edit command or through the openDocument API function. This could all be done programmatically.
The editor API is supported, but it is not documented beyond the help text in the code files themselves.
help matlab.desktop.editor
matlab.desktop.editor Summary of Editor Document functionality Programmatically access the MATLAB Editor to open, change, save, or close documents. MATLAB Version 25.2 (R2025b) 28-Jul-2025 Work with all documents open in the Editor: isEditorAvailable - Verify Editor is available. getAll - Identify all open Editor documents. Work with single document open in the Editor: getActive - Find active Editor document. getActiveFilename - Find file name of active document. findOpenDocument - Create Document object for open document. isOpen - Determine if specified file is open in Editor. Open an existing document or create a new one: newDocument - Create Document in Editor. openDocument - Open file in Editor. openAndGoToFunction - Open MATLAB file and highlight specified function. openAndGoToLine - Open file and highlight specified line. Work with text from an Editor document: indexToPositionInLine - Convert text array index to position within line. positionInLineToIndex - Convert position within line to text array index. linesToText - Convert cell array of text lines to character array. textToLines - Convert character array into cell array of text lines.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by