Create data tips at multiples points on a figure programatically

15 views (last 30 days)
I have a matrix "MyData" with size 592 by 1. After plotting I want to place datatips at 2 points. How can I create datatips programatically?
My code is
figure (1)
plot(MyData)
X_r1 = ((l +0.15)*8)/0.05 % X_r1 and X_r2 are calculated from 'l' which I input while running the code
X_r2 = (((l +0.15)*8)/0.05) + ((2*l+0.15)/0.05)
I want to crate datatips at X_r1 and X_r2! How can I create? Thank you.

Answers (1)

Walter Roberson
Walter Roberson on 27 May 2017
h = plot(MyData);
X_r1 = ((l +0.15)*8)/0.05 % X_r1 and X_r2 are calculated from 'l' which I input while running the code
X_r2 = (((l +0.15)*8)/0.05) + ((2*l+0.15)/0.05);
dcm_obj = datacursormode();
createDatatip(dcm_obj, h, [l, X_r1]);
createDatatip(dcm_obj, h, [l, X_r2]);

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!