Add cells into a square
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have the below square. How can I create a mesh of cells inside the square generated from equal subdivision on each edge?
This is how I plotted the square:
ex = [0 1 1 0];
ey = [0 0 1 1];
%visualise the polygon
pgon = polyshape(ex,ey);
figure;
plot(pgon,'EdgeColor','black','FaceColor','none','LineWidth',2)
xlabel('$x$','Interpreter','latex')
ylabel('$y$','Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
set(gca,'FontSize',12)
Thanks.
0 个评论
采纳的回答
更多回答(1 个)
Matt J
2022-6-9
编辑:Matt J
2022-6-9
ex = [0 1 1 0];
ey = [0 0 1 1];
pgon = scale(polyshape(ex,ey),1/4); %prototype
[I,J]=ndgrid((0:3)/4);
pgon=arrayfun(@(x,y)translate(pgon,x,y),I,J); %shifted copies
figure;
plot(pgon,'EdgeColor','black','FaceColor','none','LineWidth',2)
xlabel('$x$','Interpreter','latex')
ylabel('$y$','Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
set(gca,'FontSize',12)
axis equal
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call C++ from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!