point inside an area
Mostra commenti meno recenti
Hello all,
I have two points which are inside an area, when I plot them manually, it shows inside it. I am using inpolygon command so as to store all the points inside the area in an array and also segregate them. The following is the code:
w =0.4953;g = 0.5282;
%% polygon are
t = 0:0.1:20;
left_boundary_w = (t.*(t+2))./(t+1).^2;
left_boundary_g = 2*((t.*(t+3))./((t+1).*(t+2)));
lower_boundary_w = 0:0.01:0.5;
lower_boundary_g = 0.*(lower_boundary_w)-0;
right_boundary_w = 0.5:0.01:1;
right_boundary_g = 4.*(right_boundary_w(1:end))-2;
%% plot
figure
plot(left_boundary_w,left_boundary_g);hold on
plot(lower_boundary_w,lower_boundary_g)
plot(right_boundary_w,right_boundary_g)
plot(w,g,'r+','Linewidth',2')
%% Create the boundary vertices
x_boundary = [left_boundary_w, right_boundary_w, lower_boundary_w];
y_boundary = [left_boundary_g, right_boundary_g, lower_boundary_g];
figure;
plot(x_boundary, y_boundary, 'b');hold on
[in,on] = inpolygon(w, g, x_boundary, y_boundary)
if in
inside_points = [in; w, g]
end
When I use x_boundary and y_boundary, it also shows an additional fourth line. inpolygon also doesn't show the point inside the polygon.
Any help is appreciated please.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Networks in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



