Error when using isonormals on meshgrid after applying pol2cart
조회 수: 9 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
Anudeep Kumar
2025년 2월 6일 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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!