Hi all,
I have the following:
x=1;y=1;u=3;v=4;w = sqrt(u^2+v^2);
now if I use quiver(x,y,u,v) and click on the arrow by cursor, I will have x and y along with velocities in x and y axis are going to be shown. I want to my cursor to show the magnitude of the velocity which is w. For that I have watched the following video and tried to do the same job.
Following is what I have done:
function moneyplot(x,y,u,v)fh = figure;quiver(x,y,u,v,0)dcm = datacursormode(fh);datacursormode onset(dcm, 'updatefcn', @myfunction)endfunction output_txt = myfunction(obj,event_obj,w)pos = get(event_obj,'Position');output_txt = {['velocity= ',w]};if length(pos) > 2 output_txt{end+1} = ['Z: ',num2str(pos(3),4)];end
However now every time I use the cursor to choose the arrow it shows : Error in custom datatip string function. Please see the picture below. What am I doing wrong?
Will be apreciated for any kinda input.
Best Answer