0001 function mdl= mk_fmdl_from_nodes( vtx, elec_nodes, z_contact, name)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 mdl= eidors_obj('fwd_model', name);
0019
0020 for i= 1:prod(size(elec_nodes))
0021 vtx= [vtx; elec_nodes{i}];
0022 end
0023
0024
0025 vtx = unique(vtx, 'rows');
0026
0027
0028
0029 simp= delaunayn( perturb_vtx(vtx) );
0030
0031 keep= ones(size(simp,1),1);
0032 oo= ones(size(simp,2),1);
0033 for i=1:size(simp,1);
0034 area= abs(det([oo,vtx(simp(i,:),:)]));
0035 if area<1e-6; keep(i)=0;end
0036 end
0037 simp= simp(find(keep),:);
0038
0039
0040 [jnk,idx] = sort(mean(simp,2));
0041 simp= simp(idx,:);
0042
0043
0044 mdl.nodes = vtx;
0045 mdl.elems = simp;
0046
0047
0048 mdl.boundary = find_boundary( simp );
0049 mdl.gnd_node = 1;
0050
0051
0052
0053 n_elec= prod(size(elec_nodes));
0054 z_contact= z_contact.*ones(n_elec,1);
0055 for i= 1:n_elec
0056 [jnk, idxa] = intersect( vtx, elec_nodes{i},'rows');
0057 electrodes(i).nodes = idxa(:)';
0058 electrodes(i).z_contact= z_contact(i);
0059 end
0060
0061
0062 mdl.electrode = electrodes;
0063 mdl.solve= 'eidors_default';
0064 mdl.jacobian= 'eidors_default';
0065 mdl.system_mat= 'eidors_default';
0066 mdl.normalize_measurements = 0;
0067
0068
0069 function vtx_perturb= perturb_vtx( vtx );
0070 if 0
0071 ctr= mean(vtx,1);
0072 v_ctr= vtx - ones(size(vtx,1),1) * ctr;
0073 r2 = (sum(v_ctr.^2,2)) .^ (1/4);
0074 vtx_perturb = vtx + .1* v_ctr ./ (r2*ones(1,size(vtx,2)));
0075 else
0076 scl= std(vtx,1);
0077 vtx_perturb = vtx + 1e-5*randn(size(vtx)).*(ones(size(vtx,1),1)*scl);
0078 end
0079
0080
0081 function vtx_perturb= perturb_vtx_try1( vtx );
0082 max_vtx = max(vtx);
0083 min_vtx = min(vtx);
0084 vtx_perturb = vtx + 0.05*randn(size(vtx));
0085 for d= 1:size(vtx,2)
0086 idx= (vtx(:,d) == min_vtx(d)) | ...
0087 (vtx(:,d) == max_vtx(d));
0088 vtx_perturb(idx,d) = vtx(idx,d);
0089 end