www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@project/Save.m

    function OK = Save(P,FileName)
%SAVE   Save project to file
% 
%   OK = SAVE(PROJECT)
%   OK = SAVE(PROJECT,FILENAME)
%  If no file name is specified the project will overwrite the current
%  project file.
%
%   See also mbcmodel.project.SaveAs, mbcmodel.project.Load,
%   mbcmodel/LoadProject

%   Copyright 2004-2008 The MathWorks, Inc.


try
    % Get the object
    MP = P.Object;
    if nargin<2 
        % Are we trying to save a project simply called 'Untitled' without a
        % fully qualified pathname
        % Save the project
        if strcmpi(projectfile(MP), 'untitled')
            % use project name as file name
            MP = projectfile(MP,[name(MP),'.mat']);
        end
        ISSUE_WARNING = strcmpi(projectfile(MP), 'untitled.mat');
        [MP, msg] = saveMBCProject(MP);
        if ISSUE_WARNING
            % Do we need to issue a warning
            warning(message('mbc:mbcmodel:project:SaveWarning', projectfile( MP )));
        end
    else
        [MP, msg] = saveMBCProject(MP,FileName);
    end
catch
    error(message('mbc:mbcmodel:project:UnknownError2'));
end

% Do we need to throw a save error
if ~isempty(msg)
    error('mbc:mbcmodel:project:SaveError', msg);
end
OK = true;