comparison m-toolbox/classes/@LTPDAworkbench/cb_importFromMfile.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 % CB_IMPORTFROMMFILE import an m-file to a pipeline.
2 %
3 % CALL: LTPDAworkbench.cb_importFromMfile
4 %
5 % M Hewitson 13-11-08
6 %
7 % $Id: cb_importFromMfile.m,v 1.4 2010/09/17 14:09:47 ingo Exp $
8 %
9 function cb_importFromMfile(varargin)
10
11 wb = varargin{1};
12
13 % Get file from user
14 [filename, pathname] = uigetfile('*.m', 'Pick an M-file');
15 if isequal(filename,0) || isequal(pathname,0)
16 disp('User pressed cancel')
17 else
18 cmds = {};
19
20 % get file parts
21 fname = fullfile(pathname, filename);
22 [pathstr,name,ext] = fileparts(fname);
23 min = textread(fname,'%s','delimiter','\n','whitespace','');
24
25 for kk=1:numel(min)
26 line = strtrim(min{kk});
27 % Exceptions:
28 % empty lines
29 % comment lines
30 % mc
31 if ~isempty(line) && ...
32 line(1) ~= '%' && ...
33 ~strcmp(line, 'mc')
34
35 cmds = [cmds min(kk)];
36 end
37 end
38
39 % Now build the pipline
40 wb.cmds2pipeline(name, cmds);
41
42 end
43
44 end
45