??? Undefined function or variable 'k'.
조회 수: 2 (최근 30일)
이전 댓글 표시
i want to plot the convex hull of a random point and i have this msg:
my code is :
plot(x(k),y(k),'r-',x,y,'b*');
net = [1:n;rand([1,n])*x;rand([1,n])*y];
net1 = net;
hold on;
plot(net(2,:),net(3,:),'bo','MarkerSize',5,'MarkerFaceColor','b');
yy=net(3,:);
xx=net(2,:);
K= convhull(xx,yy);
plot(x(k),y(k),'r-',x,y,'b*');
댓글 수: 0
답변 (1개)
Geoff Hayes
2015년 11월 8일
ali - your above code sample is incomplete. As the error message is telling you, the variable k is undefined. And from your code, this makes sense as the first line is
plot(x(k),y(k),'r-',x,y,'b*');
which relies on k (and x and y). Given that your code is similar to an example from convhull, it could be that you need to remove the first line and then initialize the output from convhull as
k = convhull(xx,yy);
using a lower case k instead of the upper case K. This assumes that you have already initialized n, x, and y.
And..always step through the code using the MATLAB debugger. It will become much more clear where the error is and what perhaps can be done to rectify it.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bounding Regions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!