How to extract boundary of a set of 2D points
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
There is my code
LL1_x=(-0.1:.01:0.1)';
LL1=[LL1_x,-0.1*ones(length(LL1_x),1)];
LL2_y=(-0.1:.01:0.1)';
LL2=[0.1*ones(length(LL1_x),1),LL2_y];
LL3=[LL1(:,1),LL1(:,2)+0.2];
LL4=[LL2(:,1)-0.2,LL2(:,2)];
LL=[LL1;LL2;LL3;LL4]*1.6;
k = boundary(LL);
plot(LL(:,1),LL(:,2),'o');hold on
plot(LL(k,1),LL(k,2),'-')
This function works normally in most cases, but in this particular time, I didn't get the desired result. What's wrong?

0 Kommentare
Antworten (1)
Cris LaPierre
am 7 Dez. 2020
I can't describe why it picked those two points to go haywire on, and why it only appears at certain multiples (not when multiplying by 1-1.4. Appears with 1.5, 1.6, but not 1.7).
I was able to fix the issue by adding a sortrows around the vector concatenation that creates LL.
LL1_x=(-0.1:.01:0.1)';
LL1=[LL1_x,-0.1*ones(length(LL1_x),1)];
LL2_y=(-0.1:.01:0.1)';
LL2=[0.1*ones(length(LL1_x),1),LL2_y];
LL3=[LL1(:,1),LL1(:,2)+0.2];
LL4=[LL2(:,1)-0.2,LL2(:,2)];
figure
LL=sortrows([LL1;LL2;LL3;LL4]*1.6);
k = boundary(LL);
plot(LL(:,1),LL(:,2),'o');
hold on
plot(LL(k,1),LL(k,2),'-')
hold off
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
