Borrar filtros
Borrar filtros

How do I remove points which are far away from the boundary of domain?

9 visualizaciones (últimos 30 días)
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 ?

Respuesta aceptada

Matt J
Matt J el 16 de Feb. de 2023
Editada: Matt J el 16 de Feb. de 2023
Question : what can i do to remove any points which are out of the boundary nodes ?
Use inpolygon to detect which points are within the boundaries. Then discard the others.
  6 comentarios
Matt J
Matt J el 17 de Feb. de 2023
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by