Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: vectorize this part 2
Replies: 1   Last Post: Feb 1, 2012 6:58 AM

 Messages: [ Previous | Next ]
 Marios Karaoulis Posts: 89 Registered: 5/10/10
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

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);

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);

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

Date Subject Author
1/31/12 Marios Karaoulis
2/1/12 Bruno Luong