How to close .m script file in GUI with a push button?

1 Ansicht (letzte 30 Tage)
OK
OK am 19 Aug. 2019
Kommentiert: OK am 20 Aug. 2019
How to close .m script file in GUI with a push button?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Aug. 2019
Bearbeitet: Walter Roberson am 20 Aug. 2019
allEditors = matlab.desktop.editor.getAll;
Now match the filename you want to close against {allEditors.Filename} to figure out the index of the session you want to close. For example,
filenames = regexp({allEditors.Filename}, '[^/\\]+$', 'match','once');
[found, idx] = ismember(FilenameToClose, filenames);
if found
allEditors(idx).close();
end
Except that you need to be more careful than this because there can be multiple files with the same last part of the file name, distinguished by directory.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by