Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Marios Karaoulis

Posts: 88
Registered: 5/10/10
vectorize this part 2
Posted: Jan 31, 2012 3:29 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.