How to close .m script file in GUI with a push button?
    4 次查看(过去 30 天)
  
       显示 更早的评论
    
How to close .m script file in GUI with a push button? 
0 个评论
采纳的回答
  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 Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

