matlab field range now has more flexibility
parent
a85917e058
commit
6a8b6dadae
|
@ -5,9 +5,9 @@ function [field_i mesh_i] = GetField_Range(field, mesh, range)
|
|||
%
|
||||
% example:
|
||||
% % specify a mesh range
|
||||
% range{1} = [0 150] * 1e-3;
|
||||
% range{2} = [0 0];
|
||||
% range{3} = [-850 -400] * 1e-3;
|
||||
% range{1} = [0 150] * 1e-3; % x in range 0..150mm
|
||||
% range{2} = [0]; % only one line close to y==0
|
||||
% range{3} = []; % no range restriction
|
||||
%
|
||||
% % read hdf data
|
||||
% [field mesh] = ReadHDF5Dump('Et.h5');
|
||||
|
@ -25,13 +25,23 @@ function [field_i mesh_i] = GetField_Range(field, mesh, range)
|
|||
|
||||
mesh_i = mesh;
|
||||
for n=1:3
|
||||
ind_range{n} = find( mesh.lines{n}>=range{n}(1) & mesh.lines{n}<=range{n}(2));
|
||||
|
||||
if (isempty(ind_range{n}))
|
||||
ind_range{n} = find( mesh.lines{n}>=range{n}(1) , 1, 'first');
|
||||
end
|
||||
if (isempty(ind_range{n}))
|
||||
ind_range{n} = find( mesh.lines{n}<=range{n}(2) , 1, 'last');
|
||||
if (numel(range{n})==0)
|
||||
ind_range{n} = [];
|
||||
|
||||
ind_range{n} = 1:numel( mesh.lines{n});
|
||||
|
||||
elseif (numel(range{n})==1)
|
||||
ind_range{n} = find( mesh.lines{n}>=range{n}(1) , 1);
|
||||
|
||||
if (isempty(ind_range{n}))
|
||||
ind_range{n} = find( mesh.lines{n}>=range{n}(1) , 1, 'first');
|
||||
end
|
||||
if (isempty(ind_range{n}))
|
||||
ind_range{n} = find( mesh.lines{n}<=range{n}(2) , 1, 'last');
|
||||
end
|
||||
|
||||
else
|
||||
ind_range{n} = find( mesh.lines{n}>=range{n}(1) & mesh.lines{n}<=range{n}(2));
|
||||
end
|
||||
|
||||
mesh_i.lines{n} = mesh.lines{n}(ind_range{n});
|
||||
|
|
Loading…
Reference in New Issue