Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
help getting data using datacursormode

Subject: help getting data using datacursormode

From: Jonathan

Date: 8 Jan, 2010 01:08:04

Message: 1 of 2

Hello,

I have a plot from which I would like to interactively identify the xy position of various features. It looks like the datacursormode function provides the best fit since it appears to be more accurate than ginput. However, for the life of me I cannot figure out why I can't seem to get the actual text data after having clicked on a feature. Here is what I have so far...

h = figure; %Plot figure
set(h,'units','normalized','position',[0.005 0.035 0.9 0.9])
subplot(2,1,1)
plot(x,y98,'-r','LineWidth',1.5) %Plot cross-section results
hold on
plot(x,y02,'-c','LineWidth',1.5)
plot(x,y08,'-k','LineWidth',1.5)
ylabel('Elevation, NAVD88 (m)','FontSize',10)
grid on
xmin = input('Enter min profile distance > ');
xmax = input('Enter max profile distance > ');
ymin = -0.5;
ymax = 10;
axis([xmin,xmax,ymin,ymax]);
set(gca,'xdir','reverse')

dcm_obj = datacursormode(h);
set(dcm_obj,'DisplayStyle','datatip',...
    'SnapToDataVertex','on','Enable','on')

% Click on line to place datatip

text = getCursorInfo(dcm_obj);

The problem appears to be the last line which needs to be manually entered a second time in order for it to store the xy data. If I simply paste all of the above into matlab, no data is saved to text. How can it be done automatically?

Thanks
Jon

Subject: help getting data using datacursormode

From: Andy

Date: 8 Jan, 2010 03:57:03

Message: 2 of 2

"Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hi60hk$t2c$1@fred.mathworks.com>...
> Hello,
>
> I have a plot from which I would like to interactively identify the xy position of various features. It looks like the datacursormode function provides the best fit since it appears to be more accurate than ginput. However, for the life of me I cannot figure out why I can't seem to get the actual text data after having clicked on a feature. Here is what I have so far...
>
> h = figure; %Plot figure
> set(h,'units','normalized','position',[0.005 0.035 0.9 0.9])
> subplot(2,1,1)
> plot(x,y98,'-r','LineWidth',1.5) %Plot cross-section results
> hold on
> plot(x,y02,'-c','LineWidth',1.5)
> plot(x,y08,'-k','LineWidth',1.5)
> ylabel('Elevation, NAVD88 (m)','FontSize',10)
> grid on
> xmin = input('Enter min profile distance > ');
> xmax = input('Enter max profile distance > ');
> ymin = -0.5;
> ymax = 10;
> axis([xmin,xmax,ymin,ymax]);
> set(gca,'xdir','reverse')
>
> dcm_obj = datacursormode(h);
> set(dcm_obj,'DisplayStyle','datatip',...
> 'SnapToDataVertex','on','Enable','on')
>
> % Click on line to place datatip
>
> text = getCursorInfo(dcm_obj);
>
> The problem appears to be the last line which needs to be manually entered a second time in order for it to store the xy data. If I simply paste all of the above into matlab, no data is saved to text. How can it be done automatically?
>
> Thanks
> Jon

I'm not currently at MATLAB, but two recommendations:

1) If you're in data cursor mode and you create a datatip, I think there is a context menu option that says "Export Data Tip to Workspace" or something similar.

2) You can edit the update function (or text edit function, or some similar name that I can't quite remember) to store the information of the created datatips in an accessible place.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us