How do I remove points which are far away from the boundary of domain?
2 次查看(过去 30 天)
显示 更早的评论
Hi, I would like to know how do I remove points which are far away from the boundary of domain, for example
% Before
% Set points of domain:
x= [ 0 0.5 0.5 1 1 0 0 0.5 0.75 0.25 0.25];
y = [0 0 0.5 0.5 1 1 0.5 1 0.75 0.75 0.25];
% Set center points:
xc = linspace(0,1,5);
yc = linspace(0,1,5);
[xcen,ycen] = meshgrid(xc,yc);
% Plot
figure(1);
plot(x,y,'b.','MarkerSize',4);
hold on
corner = [0 0; 0.5 0; 0.5 0.5; 1 0.5; 1 1;0 1;0 0]; % visualize the boundary domain
plot(corner(:,1),corner(:,2),'-g','linewidth',0.5);
hold on
plot(xcen,ycen,'or');
hold off
% After
% % Remove center points which are far away from the boundary of domain.
idx = knnsearch(data_r,data_b,'k',1);
xc = xc(:,unique(idx));
yc = yc(:,unique(idx));
H = min(diff(xc));
Xcen = xc(1:end-1) + 0.5*H;
Ycen = yc(1:end-1) + 0.5*H;
[xcen,ycen] = meshgrid(Xcen,Ycen);
% Plot
figure(2);
plot(x,y,'b.','MarkerSize',7);
hold on
corner = [0 0; 0.5 0; 0.5 0.5; 1 0.5; 1 1;0 1;0 0]; % visualize the boundary domain
plot(corner(:,1),corner(:,2),'-g','linewidth',0.5);
hold on
plot(xcen,ycen,'or');
hold off
The problem : there is 4 red points which are out the boundary of domain!
Question : what can i do to remove any points which are out of the boundary nodes ?
0 个评论
采纳的回答
Matt J
2023-2-16
编辑:Matt J
2023-2-16
Question : what can i do to remove any points which are out of the boundary nodes ?
6 个评论
Matt J
2023-2-17
It's a warning, not an error, so maybe nothing is wrong. You can plot it as a check,
plot(polyshape(data_boundary))
I suspect that the points in data_boundary are not listed in the proper order.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!