Isinterior function causes matlab to crash
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Steven Lord
am 27 Aug. 2024
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)
[in, on] = isinterior(P, rand(10, 1), rand(10, 1))
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.
Akzeptierte Antwort
Shubham
am 27 Aug. 2024
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Elementary Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!