How to add multiple data cursors programmatically?

I have a program that plots data taken from a surface profile. I want to be able to plot multiple data points on a single figure window. I use the positions grabbed from the two data points to establish a baseline and detrend artifacts in the data. Ideally, the program will be able to take any amount of data points for purposes of detrending.
I'm running a sample with the graph of y=sinx plotting 100pts
x = linspace(-4*pi,4*pi,100); y = sin(x);
hPlot = figure; hold on plot(x,y); xlabel('Data Index'); ylabel('height - nm'); xlim([-4*pi,4*pi]); ylim([-2,2]); hold off
hObj1.SnapToDataVertex = 'off'; hObj1.DisplayStyle = 'datatip'; datacursormode on; uiwait(msgbox('Click on plot for Data Tip 1')) Obj1Info = getCursorInfo(hObj1);
hObj2 = datacursormode(hPlot); hObj2.SnapToDataVertex = 'off'; hObj2.DisplayStyle = 'datatip'; datacursormode on; uiwait(msgbox('Click on plot for Data Tip 1')) Obj2Info = getCursorInfo(hObj2);
I expect to generate one, grab the position, generate the second, and grab that position with the above program. Ideally, I would like to have "n" data cursors generated on a figure programmatically and then be able to record their data somehow.
Thanks!

回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2016 年 2 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by