DIvide an area into sectors
이전 댓글 표시
I have a xy-coordinate say (350,339), I wanted to divide the area of size 640x640 centered at the xy-coordinate into 8 sectors (angle of each sector is 45 degree)

Sir the above figure, shows what i want. The blue circle in the center is the xy-coordinate say (350,339).
I also have a set of xy-coordinates attached in the mat-file xyc.mat
I need to find the xy-coordinate closest to the center xy-coordinate in each sector and its distance
채택된 답변
추가 답변 (1개)
load xyc
x0=350; y0=339;
[X,Y]=deal(xyc(:,1), xyc(:,2));
theta=180/pi*cart2pol(X-x0,Y-y0);
theta(theta<0)=360+theta(theta<0);
[distancesAngular,imin]=min( abs(theta-linspace(45/2,360-45/2,8)) );
x=X(imin);
y=Y(imin);
scatter(X,Y); hold on
scatter(x,y,80,'filled'); hold off
axis equal
xlabel x, ylabel y
legend('Given Data','Nearest Points')
댓글 수: 2
Elysi Cochin
2022년 4월 20일
Matt J
2022년 4월 20일
@Elysi Cochin It is definitely possible, but you are far from a Matlab novice. You should be able to do it.
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

