Numbered Patches
6 次查看(过去 30 天)
显示 更早的评论
Hello all,
The matlab documentation for patch shows an example where the patch faces and vertices are numbered.
Is it possible to automatically generate a numbered plot like this or is numbering only possible by annotating?
Thanks cjm2176
0 个评论
回答(1 个)
Matt Fig
2011-5-26
It could be automated, something like:
xdata = [2 2 0 2 5;
2 8 2 4 5;
8 8 2 4 8];
ydata = [4 4 4 2 0;
8 4 6 2 2;
4 0 4 0 0];
zdata = zeros(3,5);
patch(xdata,ydata,zdata,'w')
mnx = sum(xdata)./size(xdata,1); % Or MEAN...
mny = sum(ydata)./size(ydata,1);
for ii = 1:numel(mnx)
T(ii) = text(mnx(ii),mny(ii),num2str(ii));
end
set(T,'color','b','fonts',12,'fontweight','bold')
The code after the patch creation could be put into a function M-file which takes the patch object's handle as an arg. Then from there extracts the vertices and does it's job. Of course it should go without saying that this approach will not work for certain patch shapes...
1 个评论
Walter Roberson
2011-5-26
And to answer the original question more explicitly: there is no (documented) Mathworks supplied routine or plotting option that does this on your behalf.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!