Error when using isonormals on meshgrid after applying pol2cart

9 visualizaciones (últimos 30 días)
Michael Haas
Michael Haas el 26 de Abr. de 2018
Respondida: Anudeep Kumar el 6 de Feb. de 2025 a las 15:42
Using the attached data and the following code:
[TH_45, R_45, Z_45] = meshgrid(theta_45,r_45, z_45);
[X_45,Y_45] = pol2cart(TH_45, R_45);
figure;
h = axes;
p1 = patch(isosurface(X_45, Y_45, Z_45,data,500));isonormals(X_45, Y_45, Z_45,data,p1)
p1.FaceColor = 'blue';
p1.EdgeColor = 'none';
view(-23,6);
axis tight
camlight
lighting gouraud
I get the following error meassage:
Error using interp3 (line 149) Input grid is not a valid MESHGRID.
Error in isonormals (line 75) n(:,1)=interp3(x, y, z, nx, verts(:,1), verts(:,2), verts(:,3));
I can't find the solution to that issue.

Respuestas (1)

Anudeep Kumar
Anudeep Kumar el 6 de Feb. de 2025 a las 15:42
Hey Michael,
I encountered a similar issue when trying to use isonormals after applying pol2cart. After researching the error and reviewing the documentation, I discovered that the problem arises because the interpn function, specifically interp3 in this case, requires the input values to be strictly monotonic, either increasing or decreasing, across the X1, X2, ..., Xn arrays together. It seems that the pol2cart function disrupts this condition.
What worked for me was using the output of the meshgrid function directly with isonormals. To resolve this, you might first convert your data into Cartesian coordinates and then create the meshgrid, ensuring that the dimensions match. I noticed a dimension mismatch in your data with theta_45, z_45, and r_45. If your use case permits, converting the data to Cartesian coordinates first and then generating the meshgrid could resolve the issue
I have attached the link to the latest documentation of interpn:
and a MATLAB ANSWER that talks about the same issue:
I hope it works for you.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by