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

조회 수: 2 (최근 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.

추가 답변 (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