Effacer les filtres
Effacer les filtres

Isinterior function causes matlab to crash

4 vues (au cours des 30 derniers jours)
Vinod
Vinod le 27 Août 2024
Réponse apportée : Shubham le 27 Août 2024
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 commentaire
Steven Lord
Steven Lord le 27 Août 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)
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.

Connectez-vous pour commenter.

Réponse acceptée

Shubham
Shubham le 27 Août 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!

Plus de réponses (0)

Catégories

En savoir plus sur Elementary Polygons dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by