Error using datatip() on surface. Method is not defined.

9 views (last 30 days)
I am trying to add/move datatips on figures (3d surfaces) by giving the figure number and x and y positions and havaing the program figure out the correct z value and then generate the datatip. I've boiled down my issue to this scenario.
x = 0:0.1:4;
y = 4:0.2:8;
[X,Y] = meshgrid(x,y);
Z = sin(X+Y);
srf = surf(X,Y,Z);
xVal = 3.7;
yVal = 5;
[~,xIdx] = min(abs(xVal - srf.XData(1,:)));
[~,yIdx] = min(abs(yVal - srf.YData(:,1)));
dt = datatip(srf,xVal,yVal,srf.ZData(yIdx,xIdx)); %yes, it makes me put the x and y indices backwards...
This gives the error below:
"Warning: Error occurred while executing the listener callback for event MarkedClean defined for class
Error using Method 'doGetInterpolatedPointInDataUnits' is not defined for class '' or is removed from MATLAB's search path.
Error in
Error in>@(s,e)nDelayedMove()"
It also creates a dataip at the origin (x=0, y=4) with the corect z value.
I am encountering this on both versions ' (R2020a) Update 7' and ' (R2021a) Update 4', but not when I use the latest version through which has ' (R2022a) Update 2'. There it just plots the wrong point the (x=3.2, y=4.2, z = 0.898708) until I rotate the view of the plot a bit from default and then run the last line (I'm still investigating what is the thing to do to get it to work but that seems beyond the scope of this. Solved?: Okay it seems to simulate a click on the correct spot which is behind a hump so it creates the datatip on the near face).
Do I just not have a package installed?

Answers (0)




Community Treasure Hunt

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

Start Hunting!