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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by