Why is the function isinterior filling up memory?

2 ビュー (過去 30 日間)
Seb Biass
Seb Biass 2018 年 10 月 18 日
コメント済み: Seb Biass 2018 年 10 月 19 日
Hi all,
I have matrices of x and y coordinates of size 751, 337 and a polygon with 3700 vertices. I am trying to extract the x,y coordinates of the matrix that are comprised within my polygon. I have reshaped my x and y matrices to two vectors xV and yV of size 751*337,1 and am trying to use the function isinterior:
isinterior(polyshape, xV, yV)
The code fills up both my RAM memory and HD and never completes. I am running that code on my MBP that has 16Gb of RAM and 50Gb of free space on my disk, and the activity monitor during the computation shows 44Gb of RAM used and fills up my HD until I have about 1Gb free.
Does anyone have any idea why that occurs and, alternatively, any idea of an alternative? Before 2017b I have commonly used inpolygon and inpoly (available on the file exchange) and although it has sometime be time consuming, I never had this problem of memory. I can't rely on them because my polygon has holes in it. And yes, I know my data is quite big!
Thanks a lot!
  1 件のコメント
Bruno Luong
Bruno Luong 2018 年 10 月 18 日
編集済み: Bruno Luong 2018 年 10 月 18 日
If you have a hole, for workaround, just do
in = inpolygon(..., xextern, yextern) & ...
~inpolygon(..., xintern, yintern)

サインインしてコメントする。

採用された回答

Bruno Luong
Bruno Luong 2018 年 10 月 18 日
編集済み: Bruno Luong 2018 年 10 月 18 日
Alternative? Easy just go back to INPOLYGON or even better: my FEX which is probably hard to beat in term of speed.
Just another day we speek about polyshape and I told that IMO TMW neglects the essential: speed and efficiency. Here again, it shows the very point.
theta=linspace(0,2*pi,3701);
theta(end)=[];
xv = cos(theta);
yv = sin(theta);
x = 4*rand(751,337)-2;
y = 4*rand(751,337)-2;
tic
in = inpolygon(x, y, xv, yv);
toc % Elapsed time is 7.574770 seconds..
tic
in = insidepoly(x, y, xv, yv); % My FEX
toc % Elapsed time is 0.033196 seconds.
close all
hold on
plot(xv,yv,'-');
plot(x(in),y(in),'.','markersize',0.1);
axis equal
  1 件のコメント
Seb Biass
Seb Biass 2018 年 10 月 19 日
Thanks for your rapid answer! As suggested, I went back to inpoly, everything was working in the blink of an eye. I was just really curious to see why the algorithm was filling up the memory.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by