www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/cgresload.m

    function varargout=cgresload(varargin)
% CGRESLOAD  GUI resource loader
%
%  CGRESLOAD(FILE) loads data from the mat file specified.  The
%  data will be assigned into the calling workspace.
%  s=CGRESLOAD(FILE) will return the data as fields in a structure. 
%  
%  X=CGRESLOAD(FILE,'BMP') loads data from a bitmap.
%  [X,MAP]=CGRESLOAD(FILE,'BMP') loads data and colormap from a bitmap.
%

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




if nargin<2
    TP='mat';
else
    TP=lower(varargin{2});
end
FILE=varargin{1};
pthfl=cgrespath(FILE);
switch TP
    case 'mat'
        if ~nargout
            s=load(pthfl,'-mat');
            nms=fieldnames(s);
            sref=struct('type','.','subs','');
            for n=1:length(nms)
                sref.subs=nms{n};
                assignin('caller',nms{n},subsref(s,sref));
            end
        else
            varargout{1}=load(pthfl,'-mat');
        end
    otherwise
        [varargout{1},varargout{2}]=imread(pthfl,TP);
end