facing a PointLocation error while using ginput !

Hello! HELP PLEASE! I am using the PointLocation in my script but I keep getting this error 'Undefined function 'PointLocation' for input arguments of type double', knowing that the input is a point coordinates (x,y) obtained using 'ginput' function and a delaunay triangulation (DT) such that: T= PointLocation ( DT, x,y)

5 件のコメント

Walter Roberson
Walter Roberson 2016 年 10 月 26 日
Are you creating the variable in one function and trying to use it in another function?
Ano
Ano 2016 年 10 月 27 日
編集済み: Ano 2016 年 10 月 27 日
No, all in the same script. The only input whose type is double is the delaunay triangulation, could it be the source of the problem, if so any suggestions ?! thanks
Adam
Adam 2016 年 10 月 27 日
What is PointLocation? You haven't filled in anything in the 'Products' box, but I don't see this function in base Matlab.
Ano
Ano 2016 年 10 月 27 日
Yes, in my code it is with lower p but even though I still get the error !!
Walter Roberson
Walter Roberson 2016 年 10 月 27 日
Please show how you construct DT and call pointLocation

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

 採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 27 日
編集済み: Walter Roberson 2017 年 7 月 25 日

0 投票

10 件のコメント

Walter Roberson
Walter Roberson 2016 年 10 月 28 日
You have gotten confused between delaunay() and delaunayTriangulation() . The one you are using produces a numeric matrix, which cannot be used with pointPosition .
Ano
Ano 2016 年 10 月 28 日
well it did prevent the error from appearing.Thank you ! Best regards!
ABDUL REHMAN
ABDUL REHMAN 2017 年 7 月 24 日
Dear Ano, How you get rid of the error.? 'Undefined function 'PointLocation' for input arguments of type double' I am getting same error. kindly suggest me a way.
Thanks
Walter Roberson
Walter Roberson 2017 年 7 月 24 日
See my answer about the using delaunayTriangulation as the function name.
ABDUL REHMAN
ABDUL REHMAN 2017 年 7 月 25 日
編集済み: Walter Roberson 2017 年 7 月 25 日
Thanks, I have changed it to delaunayTriangulation. TRI = delaunayTriangulation(X,Y);
The error now saying
"Error using delaunayTriangulation
The input points must be specified in column-vector format."
I have changed it again to
TRI = delaunayTriangulation([X',Y']);
Now the error shifted to next line saying
"Error using delaunayTriangulation/subsasgn
Invalid arguments in indexing operation."
Error in...
"t(4,:)=0;"
This is the code.
TRI = delaunayTriangulation([X',Y']);
t=TRI';
t(4,:)=0;
Walter Roberson
Walter Roberson 2017 年 7 月 25 日
The TRI returned from delaunayTriangulation is an object . You cannot index all columns of an object.
I am not sure what you are trying to do with that statement.
ABDUL REHMAN
ABDUL REHMAN 2017 年 7 月 25 日
Thanks, Actually I want to create mesh structure using delaunayTriangulation and then pick some triangles using graphical input, "ginput". When i used just "delaunay" it gives me indexing array. but when i use delaunayTriangulation it gives me object, which can't be used as an indexing operation.
Walter Roberson
Walter Roberson 2017 年 7 月 25 日
ginput returns coordinates. Pass those as the second argument to pointLocation. The second output is the coordinates of the vertices if you need coordinates. The first output is the triangle ID. If for some reason the coordinates are not enough and you need to index by the triangle ID then use the CoordinatePositions method of the triangulation.
ABDUL REHMAN
ABDUL REHMAN 2017 年 7 月 26 日
編集済み: Walter Roberson 2017 年 7 月 26 日
Thnaks again for your help, I m posting here my code, still getting error.
h=0.01;
L=0.10;
W=0.05;
Nx=17;
Ny=9;
Number=3;
epsilon=1e-6;
M=1;
for i=1:Nx+1
for j=1:Ny+1
X(M)=-L/2+(i-1)/Nx*L;
Y(M)=-W/2+(j-1)/Ny*W-epsilon*X(M);
M=M+1;
end
end
TRI = delaunayTriangulation([X',Y']);
t=TRI';
t(4,:)=0;
p=[X; Y; -h*ones(1,length(X))];
save plate p t
PatchNumber=[];
viewer plate; view(0,90); hold on
m=0;
while ~isempty(t)
m=m+1;
[xi,yi]=ginput;
TriangleNumber = pointLocation(TRI,xi,yi);
n=t(1:3,TriangleNumber);
PatchNumber= [PatchNumber TriangleNumber];
x= p(1,n);
y= p(2,n);
if isempty(xi|yi) break; end
fill(x,y,Color4)
clear xi yi
end
t(4,:)=3;
t(4,PatchNumber)=2;
save plate p t
with the delaunayTriangulation, the error is what I mentioned above.
"Error using delaunayTriangulation/subsasgn
Invalid arguments in indexing operation."
Error in...
"t(4,:)=0;"
When I use just delaunay it runs but gives error at pointLocation when I pick the points using ginput, with the input type double.
Walter Roberson
Walter Roberson 2017 年 7 月 26 日
It is meaningless to set the 4th column of a triangulation object.

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

その他の回答 (1 件)

Ano
Ano 2016 年 10 月 28 日

0 投票

the DT was constructed as it follow:
N=20; %Discretization parameter
L=50; % Length
for i=1:N+1 %descritisation
for j=1:N+1
X(i)=-L/2+(i-1)/N*L;
Y(j)=-L/2+(j-1)/N*L;
end
end
DT = delaunay(X,Y);
DTt=DT';
while ~isempty(DTt)
[x,y]=ginput(1);
T = pointLocation ( DT, x ,y);
end

カテゴリ

ヘルプ センター および File ExchangeSpatial Search についてさらに検索

タグ

質問済み:

Ano
2016 年 10 月 26 日

コメント済み:

2017 年 7 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by