0001 function num = elem_dim( mdl );
0002
0003
0004
0005
0006
0007
0008
0009 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0010
0011 if ~isfield(mdl,'type') && isfield(mdl,'elems')
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.elems,2)-1;
0024
0025 function do_unit_test
0026 mdl = mk_common_model('a2c2',8);
0027 ne = elem_dim( mdl );
0028 unit_test_cmp('test1', ne, 2);
0029
0030 mdl = mk_common_model('n3r2',[16,2]);
0031 ne = elem_dim( mk_image( mdl ));
0032 unit_test_cmp('test2', ne, 3);