Mercurial > hg > ltpda
diff m-toolbox/test/gui/functions/gltpda_aoImport.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/test/gui/functions/gltpda_aoImport.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,81 @@ +function handles = gltpda_aoImport(handles) + +% GLTPDA_AOIMPORT import an analysis object from file +% +% M Hewitson 15-02-07 +% +% $Id: gltpda_aoImport.m,v 1.2 2007/03/23 06:47:24 hewitson Exp $ +% + +% init output +newaos = []; + +% Load object(s) +% get filename +[filename, pathname] = uigetfile({... + '*.txt', '2-column ascii';... + '*.mat', 'MAT-files';... + '*.xml', 'LTPDA XML file'},... + 'MAT-file input',... + 'MultiSelect', 'on') + +% Loop over selected files +if iscellstr(filename) + nfiles = length(filename); + for f=1:nfiles + infile = fullfile(pathname, char(filename(f))); + a = readFromFile(infile); + newaos = [newaos a]; + end +else + nfiles = 1; + infile = fullfile(pathname, filename); + a = readFromFile(infile); + newaos = [newaos a]; +end + + +% Get current array of AOs +aos = getappdata(handles.main, 'aos'); + +% Add to object array +aos.objs = [aos.objs newaos]; +aos.nobjs = aos.nobjs + length(newaos); + +% Set array +setappdata(handles.main, 'aos', aos); + +% Update object list +gltpda_setAOlist(handles); + +% Set focus to new object + +%-------------------------------------------------------------------------- +% +function a = readFromFile(infilename) + +disp(['* reading ' infilename]); + + % Switch over different file types + [path,name,ext,vers] = fileparts(infilename); + + switch ext + case '.mat' + + in = load(infilename) + + case '.txt' + + a = ao(infilename); + + case '.xml' + + a = ao(infilename); + + otherwise + error('### unknown file format.'); + end + + + +% END \ No newline at end of file