IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uip_block_cascade_base.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Calls Properties GUIs for all component blocks
4 %
5 %> @param blk instance of block to be created
6 %> @param input (optional) Input to block
7 function varargout = uip_block_cascade_base(varargin)
8 global blk;
9 blk = varargin{1};
10 input = []; flag_input = 0;
11 if nargin >= 1 && ~isempty(varargin{2})
12  input = varargin{2};
13  flag_input = 1;
14 end;
15 output.flag_ok = 0;
16 output.params = {};
17 
18 no_blocks = numel(blk.blocks);
19 params = {};
20 for i = 1:no_blocks
21  z = blk.blocks{i}.get_params(input);
22 
23  if ~z.flag_ok
24  break;
25  end;
26 
27  if i < no_blocks
28  % Transforms input
29  blk.blocks{i} = blk.blocks{i}.boot();
30  end;
31 
32  if isfield(z, 'params') % bit of tolerance
33  for j = 1:2:numel(z.params)
34  z.params{j} = ['blocks{', int2str(i), '}.', z.params{j}];
35  end;
36  params = [params, z.params]; % Goes collecting params
37 
38  if i < no_blocks
39  for j = 1:2:numel(z.params)-1
40  s_code = sprintf('global blk; blk.%s = %s;', z.params{j}, z.params{j+1});
41  evalin('base', s_code);
42  end;
43  end;
44  end;
45 
46  if i < no_blocks && flag_input
47  blknow = blk.blocks{i}.train(input);
48  input = blknow.use(input);
49  end;
50 
51  if i == no_blocks
52  output.flag_ok = 1;
53  output.params = params;
54  end;
55 end;
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 varargout{1} = output;
Base Block class.
Definition: block.m:2
function uip_block_cascade_base(in varargin)