フィルターのクリア

The query points have inconsistent spatial dimension

2 ビュー (過去 30 日間)
biot0p
biot0p 2022 年 4 月 26 日
コメント済み: biot0p 2023 年 10 月 18 日
Hi,
I have a triangular mesh, and I am trying to obtain the triangle indices at picked point locations.
tri = triangulation(data.econn,data.r);
disp(['Pick ',num2str(Npts),'query points . . .']);
p0=ginput(Npts);
x0=p0(:,1); y0=p0(:,2);
scatter(x0,y0, 'filled') %visualize query points
pointLocation(tri,x0,y0); %Error using triangulation/pointLocation: %The query points have inconsistent spatial dimension.
Whatever location I choose, I end up with the same error:
Error using triangulation/pointLocation
The query points have inconsistent spatial dimension.
x0 and y0 are column-vectors of the same size... Can someone indicate what's wrong with my code?
Thank you!

採用された回答

Shivam
Shivam 2023 年 10 月 18 日
Hi,
From the information provided, I understand that you are getting an error while executing pointLocation(tri, x0, y0) with 'tri' as the triangulation object and 'x0' and 'y0' as coordinates obtained from ginput.
The error occurs because the 'pointLocation' function expects the query points to have the same number of dimensions as the triangulation object. Here, the query points, i.e., (x0, y0), are 2-D and 'tri' is 3-D.
>> tri
tri =
triangulation with properties:
Points: [542×3 double]
ConnectivityList: [984×3 double]
In this case, you can delete the third column of data.r to get the 2-D triangulation object, considering z-coordinate for every point is 0:
data.r(:,3) = [];
>> tri
tri =
triangulation with properties:
Points: [542×2 double]
ConnectivityList: [984×3 double]
You can refer to the following documentation to know more about ginput, triangulation and pointLocation:
  1. https://www.mathworks.com/help/releases/R2023a/matlab/ref/ginput.html
  2. https://www.mathworks.com/help/releases/R2023a/matlab/ref/triangulation.html
  3. https://www.mathworks.com/help/releases/R2023a/matlab/ref/triangulation.pointlocation.html
I hope it helps in resolving the error.
Thanks,
Shivam
  1 件のコメント
biot0p
biot0p 2023 年 10 月 18 日
Hi, that makes a lot of sense! thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by