create datatip on a surface

8 vues (au cours des 30 derniers jours)
reza aghaee
reza aghaee le 8 Juil 2020
Commenté : reza aghaee le 30 Jan 2021
a = 0 : 0.1 : 1;
b = 0 : 0.1 : 1;
[bb,aa] = meshgrid(b,a);
Acc = aa.^2 - bb.^2;
ss = surf(aa,bb,Acc);
c = a(2)^2 - b(4).^2;
datatip(ss,a(2),b(4),c);
Hi,
why this part of my code does not work correctly?
I want to create datatip on 0.1,0.3,-0.08 but it create on 0,0,0

Réponse acceptée

Takashi Matsubara
Takashi Matsubara le 22 Jan 2021
I have the same problem.
In surf or mesh, datatip with coordinate x,y,z may not work correctly.
datatip with 'DataIndex' may work correctly.
For DataIndex, sub2ind can be used.
In this case, below code may work correctly.
a = 0 : 0.1 : 1;
b = 0 : 0.1 : 1;
[bb,aa] = meshgrid(b,a);
Acc = aa.^2 - bb.^2;
ss = surf(aa,bb,Acc);
c = a(2)^2 - b(4).^2;
id=sub2ind(size(Acc),2,4);
datatip(ss,'DataIndex',id);
  1 commentaire
reza aghaee
reza aghaee le 30 Jan 2021
Thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by