com.mathworks.mlservices.MLEditorservice
개체를 사용하여 편집기에 액세스하고 더티 파일을 모두 저장할 수 있습니다. 이 기능 (의존성)의 목록을 전달하고 단지 사람들을 절약 할 수 있도록
service = com.mathworks.mlservices.MLEditorServices;
% Get a vector of all open editors
editors = service.getEditorApplication.getOpenEditors();
% For each editor, if it is dirty, save it
for k = 0:(editors.size - 1)
editor = editors.get(k);
if editor.isDirty()
editor.save();
end
end
오히려 맹목적으로 모든 파일을 저장하는 것보다, 당신은 약간이를 수정할 수 있습니다.
function saveAll(varargin)
% Convert all filenames to their full file paths
filenames = cellfun(@which, varargin, 'uniformoutput', false);
service = com.mathworks.mlservices.MLEditorServices;
% Get a vector of all open editors
editors = service.getEditorApplication.getOpenEditors();
% For each editor, if it is dirty, save it
for k = 0:(editors.size - 1)
editor = editors.get(k);
% Check if the file in this editor is in our list of filenames
% and that it's dirty prior to saving it
if ismember(char(editor.getLongName()), filenames) && editor.isDirty()
editor.save();
end
end
end
그리고이
saveAll('myfunc', 'myotherfunc')
(문자열로) 여러 함수 이름으로 호출 할 수있는 당신이 여기에 "더러운"의 의미를 명확히 제시 이익을 위해 (수정되었지만 저장되지 않은 파일) 모국어가 아닌 사람 –