www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/cgdcminterface.m
function [cal, ok] = cgdcminterface(options) %CGDCMINTERFACE Get a calibration interface to an ETAS INCA DCM file. % [CAL,OK] = CGDCMINTERFACE(OPTIONS) returns a % calibrationdata.dcminterface CAL and a status flag OK. Valid OPTIONS % are 'r' for 'read' and 'w' for 'write (create if necessary)'. % % CGDCMINTERFACE is equivalent to CGDCMINTERFACE('r'). % Copyright 2000-2016 The MathWorks, Inc. narginchk(0,1) if nargin == 0, options = 'r'; end % Get filename switch lower(options) case 'r' [filename, pathname] = uigetfile({'*.dcm','DCM files (*.dcm)'}, 'Open'); case 'w' [filename, pathname] = uiputfile({'*.dcm','DCM files (*.dcm)'}, 'Save As'); otherwise error(message('mbc:cgdcminterface:InvalidArgument')); end if isequal(filename,0) || isequal(pathname,0) % User canceled cal = []; ok = false; else % Provide default extension .dcm filename = fullfile(pathname, filename); [pathname, filename, extension] = fileparts(filename); if isempty(extension), extension = '.dcm'; end filename = fullfile(pathname, [filename extension]); switch lower(options) case 'w' [ok, postfcn] = pSetupFileWrite(filename); action = 'saving'; case 'r' ok = true; postfcn = []; action = 'loading'; otherwise error('Invalid option') end if ok try % Create interface cal = calibrationdata.dcminterface; % Load cal.ProgressManager = cgcalgui.progressmanager; cal.Filename = filename; ok = true; catch ME msg = sprintf('Error %s INCA DCM file:\n\n%s', action, ME.message); h = errordlg(msg, 'Error', 'modal'); waitfor(h); cal = []; ok = false; end if ~isempty(postfcn) postfcn(ok); end else cal = []; end end