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!