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!