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
 If there is a vector of mdls, return the dimension of the first

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 % If there is a vector of mdls, return the dimension of the first
0007 
0008 % $Id: mdl_dim.m 5112 2015-06-14 13:00:41Z aadler $
0009 
0010 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0011 
0012 if ~isfield(mdl,'type') && isfield(mdl,'nodes') % Set default for this case
0013    mdl.type = 'fwd_model';
0014 end
0015 
0016 switch mdl(1).type
0017   case 'image';      fmdl = mdl.fwd_model;
0018   case 'inv_model';  fmdl = mdl.fwd_model;
0019   case 'fwd_model';  fmdl = mdl;
0020   otherwise;
0021       error('can''t process model of type %s', mdl.type );
0022 end
0023 
0024 num = size(fmdl.nodes,2);
0025 
0026 function do_unit_test
0027    mdl = mk_common_model('a2c2',8);
0028    ne = mdl_dim( mdl );
0029    unit_test_cmp('test1', ne, 2);
0030 
0031    mdl = mk_common_model('n3r2',[16,2]);
0032    ne = mdl_dim( mk_image( mdl ));
0033    unit_test_cmp('test1', ne, 3);
0034

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005