0001 function num = mdl_dim( mdl );
0002
0003
0004
0005
0006
0007
0008
0009 if isstr(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0010
0011 if ~isfield(mdl,'type') && isfield(mdl,'nodes')
0012 mdl.type = 'fwd_model';
0013 end
0014
0015 switch mdl.type
0016 case 'image'; fmdl = mdl.fwd_model;
0017 case 'inv_model'; fmdl = mdl.fwd_model;
0018 case 'fwd_model'; fmdl = mdl;
0019 otherwise;
0020 error('can''t process model of type %s', mdl.type );
0021 end
0022
0023 num = size(fmdl.nodes,2);
0024
0025 function do_unit_test
0026 mdl = mk_common_model('a2c2',8);
0027 ne = mdl_dim( mdl );
0028 ok='fail'; if ne==2; ok='ok'; end; fprintf('test1: %10s\n',ok);
0029
0030 mdl = mk_common_model('n3r2',16);
0031 ne = mdl_dim( mk_image( mdl ));
0032 ok='fail'; if ne==3; ok='ok'; end; fprintf('test2: %10s\n',ok);