How can I add an associated variable to a point using the figure's data tip feature while hovering over the point with the mouse.
4 ビュー (過去 30 日間)
古いコメントを表示
I'm making an App in App Designer that will allow the user to develop a flight plan given a set of predeterimed data collection lines. I would like the user to be able to select one of the graphed waypoints in a map where I used the function geoshow to map various points and the lines that connect them. Each of these points has a point name. To help the user find the point they want to select I would like to alter the curser data tip to include the point name when the user hovers over the point with the mouse. I have found a method to change the labels of the x and y in the data tip, but I can't seem to figure out how to pass information, such as the point name into the data tip.
I have tried the following in my code:
fig = gcf;
dcm_obj = datacursormode(fig);
set(dcm_obj,'UpdateFcn',@newTitle);
with an accompanying function:
function title = newTitle(empt,event_obj,waypoints)
% Get the position of the point being clicked on
pos = get(event_obj,'Position');
% Find point name for point
pointIndex = find(pos(1),waypoints.Lat);
name = waypoints.Name(pointIndex);
title = {[name];['Lattitude: ',num2str(pos(1))]; ['Longitude: ',num2str(pos(2))]};
end
But, Matlab does not actually pass the structure variable waypoints to the function newTitle using the @newTitle command in set().
0 件のコメント
回答 (1 件)
Harsha Priya Daggubati
2019 年 10 月 9 日
Hi,
You can pass additional variable waypoint to the newTitle function in 'set' method as follows:
set(dcm_obj,'UpdateFcn',{@newTitle,waypoints});
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!