www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@localmod/DisplayFit.m

    function DisplayFit(L, sFunc)
%DISPLAYFIT  Update output display with new information
%
%  DISPLAYFIT(M, STR) appends the new string STR to the current output
%  handle.  If no handle is currently set, no action is taken.
%
%  DISPLAYFIT(M, FUNC) calls the specified function handle to generate a
%  string.  The function is only called if a valid display handle has been
%  set.

%  Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc.


if ischar(sFunc)
    % Create a function handle to return the string when called.
    sFunc = @() sFunc;
end

h = L.FitOptions.DispHndl;
if ~isempty(h)
    if h==0
        % Output to command window
        fprintf(sFunc());
        fprintf('\n');
    elseif isgraphics(h) && strcmp(get(h,'Visible'),'on')
        % Output to graphics handle
        if ~isempty(findobj(h,'Type','uicontrol','Style','listbox'))
            OldStr = get(h,'String');
            NewStr = [OldStr; {sFunc()}];
            set(h,'String',NewStr,'ListboxTop',max(length(NewStr)-5,1),'Value',length(NewStr));
        else
            set(h,'String',sFunc());
        end
        drawnow('expose');
    end
end