elem_dim

PURPOSE ^

ELEM_DIM: dimension of elements in space (are elements in 2D or 3D space)

SYNOPSIS ^

function num = elem_dim( mdl );

DESCRIPTION ^

 ELEM_DIM: dimension of elements in space (are elements in 2D or 3D space)
  Note, elem_dim is not the same as the model dimention (can have 2D models in 3D space)
 num_dim = elem_dim( mdl );
    = 2 if 2D, 3 if 3D

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function num = elem_dim( mdl );
0002 % ELEM_DIM: dimension of elements in space (are elements in 2D or 3D space)
0003 %  Note, elem_dim is not the same as the model dimention (can have 2D models in 3D space)
0004 % num_dim = elem_dim( mdl );
0005 %    = 2 if 2D, 3 if 3D
0006 
0007 % $Id: elem_dim.m 5112 2015-06-14 13:00:41Z aadler $
0008 
0009 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0010 
0011 if ~isfield(mdl,'type') && isfield(mdl,'elems') % Set default for this case
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);

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005