How to improve performance of code ?
Afficher commentaires plus anciens
Hello all, I am using this code for getting the data point coordinates among defined vertices .
ver = vertice; % nX3 matrix
ver=ceil(ver);
tess=delaunay(ver);
mn_x=min(ver(:,1));
mx_x=max(ver(:,1));
mn_y=min(ver(:,2));
mx_y=max(ver(:,2));
mn_z=min(ver(:,3));
mx_z=max(ver(:,3));
[X,Y,Z]=ndgrid(mn_x:0.8:mx_x , mn_y:0.8:mx_y , mn_z:0.8:mx_z);
sz=size(X);
P=ones(sz(1)*sz(2)*sz(3),3);
for i=1:sz(1)*sz(2)*sz(3)
P(i,1)=X(i);
P(i,2)=Y(i);
P(i,3)=Z(i);
end
pts=zeros(size(P));
for j=1:length(P)
t=tsearchn(ver,tess,P(j,:));
isin=~isnan(t);
if isin ==1
pts(j,:)=P(j,:);
end
end
It works fine but takes a lot time to calculate. How to improve the performance of code ? Thank you :)
4 commentaires
Geoff Hayes
le 28 Fév 2016
yogesh - please quantify what you mean by it takes a lot of time. What are the dimensions of vertice? Is delaunay a function built-in to MATLAB (see http://www.mathworks.com/help/matlab/ref/delaunay.html) or something that you have written?
yogesh jain
le 29 Fév 2016
Modifié(e) : yogesh jain
le 29 Fév 2016
Jan
le 29 Fév 2016
@yogesh jain: It matters if you are talking about day or micro-seconds. n might be 1e3 or 1e10, so please be specific and do not let us guess the details.
yogesh jain
le 29 Fév 2016
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spatial Search dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!