Numbered Patches

7 ビュー (過去 30 日間)
Colin
Colin 2011 年 5 月 26 日
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

回答 (1 件)

Matt Fig
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
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 ExchangePolygons についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by