Isinterior function causes matlab to crash

3 ビュー (過去 30 日間)
Vinod
Vinod 2024 年 8 月 27 日
回答済み: Gojo 2024 年 8 月 27 日
I am using the isinterior function in my matlba script. It produces the following error:
Requested 500X5500000 (22.0GB) array exceeds maximum array size preference (7.9GB). This might cause MATLAB to
become unresponsive.
Error in polyshape/isinterior>check_inpolygon (line 65)
x = x(ones(Nv,1),:);
Error in polyshape/isinterior (line 50)
[in, on] = check_inpolygon(X, Y, xv, yv, tol);
I have very simple code and I just need to check which points are in the inside of the shape. Why am I getting error.
How to fix?
Pleas help
  1 件のコメント
Steven Lord
Steven Lord 2024 年 8 月 27 日
What is the size of the vertices in your polyshape and what are the sizes of the arrays of query point coordinates (the x and y inputs or the P input) in your call to isinterior?
For example, in this call:
P = nsidedpoly(8)
P =
polyshape with properties: Vertices: [8x2 double] NumRegions: 1 NumHoles: 0
[in, on] = isinterior(P, rand(10, 1), rand(10, 1))
in = 10x1 logical array
0 1 1 1 1 1 1 1 1 1
on = 10x1 logical array
0 0 0 0 0 0 0 0 0 0
the polyshape object P has 8 vertices and the sizes of both x and y are [10 1]. I suspect your coordinates are not vectors of the same size but are vectors with different orientations that generate in and on outputs that are matrices rather than vectors.

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

採用された回答

Gojo
Gojo 2024 年 8 月 27 日
Hey Vinod,
I understand that you are using the "isinterior" function to check for points present inside the polyshape and you are encountering an error. I believe the number of query points are too large to be computed over a single function call.
As the error message suggests that the requested array exceeds the maximum size preferences, I would suggest you to first maximize the array preferences in settings if your system has more available space. I would also suggest you to create chunks of the query points and use the function "isinterior" in batches to stay in the memory limitations.
The error message you are encountering is very similar to the one present in the following MATLAB Answer: https://www.mathworks.com/matlabcentral/answers/2123021-how-to-resolve-the-error-for-creating-mask-from-shape-file#answer_1478916?s_tid=prof_contriblnk
In this MATLAB Answer, I have explained the steps you can follow to modify your preferences and use batch processing as a workaround to resolve the memory issues you are encountering while using the "isinterior" function.
I hope this helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by