comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 function handles = gltpda_aoImport(handles)
2
3 % GLTPDA_AOIMPORT import an analysis object from file
4 %
5 % M Hewitson 15-02-07
6 %
7 % $Id: gltpda_aoImport.m,v 1.2 2007/03/23 06:47:24 hewitson Exp $
8 %
9
10 % init output
11 newaos = [];
12
13 % Load object(s)
14 % get filename
15 [filename, pathname] = uigetfile({...
16 '*.txt', '2-column ascii';...
17 '*.mat', 'MAT-files';...
18 '*.xml', 'LTPDA XML file'},...
19 'MAT-file input',...
20 'MultiSelect', 'on')
21
22 % Loop over selected files
23 if iscellstr(filename)
24 nfiles = length(filename);
25 for f=1:nfiles
26 infile = fullfile(pathname, char(filename(f)));
27 a = readFromFile(infile);
28 newaos = [newaos a];
29 end
30 else
31 nfiles = 1;
32 infile = fullfile(pathname, filename);
33 a = readFromFile(infile);
34 newaos = [newaos a];
35 end
36
37
38 % Get current array of AOs
39 aos = getappdata(handles.main, 'aos');
40
41 % Add to object array
42 aos.objs = [aos.objs newaos];
43 aos.nobjs = aos.nobjs + length(newaos);
44
45 % Set array
46 setappdata(handles.main, 'aos', aos);
47
48 % Update object list
49 gltpda_setAOlist(handles);
50
51 % Set focus to new object
52
53 %--------------------------------------------------------------------------
54 %
55 function a = readFromFile(infilename)
56
57 disp(['* reading ' infilename]);
58
59 % Switch over different file types
60 [path,name,ext,vers] = fileparts(infilename);
61
62 switch ext
63 case '.mat'
64
65 in = load(infilename)
66
67 case '.txt'
68
69 a = ao(infilename);
70
71 case '.xml'
72
73 a = ao(infilename);
74
75 otherwise
76 error('### unknown file format.');
77 end
78
79
80
81 % END