mdl_dim

PURPOSE ^

MDL_DIM: dimension of model space (are nodes in 2D or 3D space)

SYNOPSIS ^

function num = mdl_dim( mdl );

DESCRIPTION ^

 MDL_DIM: dimension of model space (are nodes in 2D or 3D space)
  Note, mdl_dims is not the same as the element dimentions
 num_dim = mdl_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 = mdl_dim( mdl );
0002 % MDL_DIM: dimension of model space (are nodes in 2D or 3D space)
0003 %  Note, mdl_dims is not the same as the element dimentions
0004 % num_dim = mdl_dim( mdl );
0005 %    = 2 if 2D, 3 if 3D
0006 
0007 % $Id: mdl_dim.html 2819 2011-09-07 16:43:11Z aadler $
0008 
0009 if isstr(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0010 
0011 if ~isfield(mdl,'type') && isfield(mdl,'nodes') % 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.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);

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005