Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
vectorize this part 2
Posted:
Jan 31, 2012 3:29 PM
|
|
Hi all
I have 3 vectors mesh.x_centers, mesh.y_centers, mesh.z_centers, defying some 3D ponts on a mesh.
I need to check each of these points, in which are they belong. This area is defined in another matrix, mesh.param_i, where column 4 and 5 show the x's (from-to), column 7-8 the ys and column 9-10 the zs.
Is any other more efficient way to program this? The find command is rather slow.
%now find which elements belong to each parameter mesh.jtmp=zeros(10000,mesh.num_param); for i=1:mesh.num_param
% start with x's ind1=find(mesh.x_centers>=mesh.param_i(i,4)); ind2=find(mesh.x_centers<=mesh.param_i(i,5)); ind_x=intersect(ind1,ind2);
% start with y's ind1=find(mesh.y_centers>=mesh.param_i(i,6)); ind2=find(mesh.y_centers<=mesh.param_i(i,7)); ind_y=intersect(ind1,ind2);
% start with z's ind1=find(mesh.z_centers>=mesh.param_i(i,8)); ind2=find(mesh.z_centers<=mesh.param_i(i,9)); ind_z=intersect(ind1,ind2);
ind=intersect(ind_x,ind_y); ind=intersect(ind,ind_z);
mesh.jtmp(1:length(ind),i)=ind;
end
|
|
|
|