Numbered Patches

5 vues (au cours des 30 derniers jours)
Colin
Colin le 26 Mai 2011
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

Réponses (1)

Matt Fig
Matt Fig le 26 Mai 2011
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 commentaire
Walter Roberson
Walter Roberson le 26 Mai 2011
And to answer the original question more explicitly: there is no (documented) Mathworks supplied routine or plotting option that does this on your behalf.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by