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

1 回表示 (過去 30 日間)
OK
OK 2019 年 8 月 19 日
コメント済み: OK 2019 年 8 月 20 日
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.
  1 件のコメント
OK
OK 2019 年 8 月 20 日
Nice, it worked well. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by