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

2 次查看(过去 30 天)
How to close .m script file in GUI with a push button?

采纳的回答

Walter Roberson
Walter Roberson 2019-8-20
编辑:Walter Roberson 2019-8-20
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by