Division of a square
1 回表示 (過去 30 日間)
古いコメントを表示
I have a square with vertices [0,0,1; 1,0,1; 1,1,1;0,1,1] I want to divide this square into 'n' number of equal squares. Lets say 16 equal squares. Could any one tell me the simplest way to do this?
thanks
0 件のコメント
採用された回答
Matt Fig
2011 年 5 月 16 日
I am not sure this is what you mean, but here is a graphical demonstration of what I think you mean.
% Data
n = 16; % Divide into n equal squares.
T = [0,0,1; 1,0,1; 1,1,1;0,1,1];
%
%
%
% Do the work:
m = 1/sqrt(n); % m should be an integer. Possibly add error check.
subplot(1,2,1)
patch(T(:,1),T(:,2),T(:,3),'b')
axis square
subplot(1,2,2)
hold on
SS = cell(1/m,1/m);
for ii = 1:1/m
for jj = 1:1/m
M = [T(:,1)*m+(ii-1)*m T(:,2)*m+(jj-1)*m T(:,3)];
patch(M(:,1),M(:,2),M(:,3),rand)
SS{ii,jj} = M; % Hold the arrays for further processing....
end
end
axis square
Note that if you don't need the graphics, you can just take that out of the loop.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!