Form maximum unique squares with centers in a given area

조회 수: 1 (최근 30일)
Tejas
Tejas 2020년 10월 15일
편집: Tejas 2020년 10월 15일
I have an array attached to this question. This array is composed of gridpoints converted into indices for a 100x100 area. Doing
[x,y] = ind2sub([100,100],K(:,1));
plot(x,y,'r.')
axis([1,100,1,100])
gives the following figure.
Each of the points in the first row of K is the center of the square formed by the rest of the points in that column. The side of each square is 9, thus there are 81 points in each square. There are 1080 points in the figure, and with each of the points being a center of the square, 1080 squares can be formed. However, I want distinct non-overlapping squares. If I do
K2 = K(:,1);
for i = 2:size(K,2)
if ~any(ismember(K2,K(:,i)))
K2(:,end+1) = K(:,i);
end
end
[x2,y2] = ind2sub([100,100],K2)
plot(x2,y2,'b.')
I get something like this
Since there are 16 columns in K2, it means 16 non-overlapping squares can be fit whose centers are one of the red points. I'm wondering if that is the maximum number of squares possible in such a case. If not, how can I find the maximum?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by