slow down the for loop operation for huge set of datas

1 次查看(过去 30 天)
Hello Team,
I would like to increase the search operation in quite faster way, the below code i have implemented takes atleast 40mins to complete it because i have very huge data
for i = 1:length(LocationsListData.x) % which is approximately 26532957
idx = inpolygon(X(:),Y(:),LocationsListData.x(i),LocationsListData.y(i)) ;% X and Y has 4196*4196 size for each element
idx(idx==0)=[];
if~isempty(idx)
value(i) = idx;
end
end
do you see any possiblities to reduce the speed ? if so and then how can i do that ?
  5 个评论
SatyaPrakash Gupta
Hii Darova,
please find the locationListdata attaced in the below link.
there is no polygon available , i have grid where i use to search for available data in each grid using inpolygon function

请先登录,再进行评论。

回答(1 个)

Mohammad Sami
Mohammad Sami 2020-4-3
You don't need to use the for loop with the inpolygon function.
idx = inpolygon(X(:),Y(:),LocationsListData.x,LocationsListData.y);

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by