4.52941

4.5 | 20 ratings Rate this file 34 Downloads (last 30 days) File Size: 9.26 KB File ID: #2875
image thumbnail

dualcursor

by Michelle Hirsch

 

20 Dec 2002 (Updated 21 Sep 2011)

Add dual vertical cursors to a plot.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

Dual cursors are useful for picking relative measurements off of a plot; for instance - calculate the period of a time series, or the relative amplitude of two frequencies. A picture's worth a thousand words, so take a peek.

Key Features:
 - Basic syntax: dualcursor on / dualcursor off
 - Extended syntax supports a high level of control
 - Works with live data streams
 - Works in GUIDE guis
 - Includes delta calculations (x2-x2, y2-y1)
 - Export selected region to a new figure or to the workspace

Acknowledgements

Octave inspired this file.

This file inspired Dualcursor2, Stackobj, Speech Analysis Using Lpc, and Dtmcursor.

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
annotation(3), crosshair, cursor, cursors(2), customization, datalabel, ginput, graphics, label, marker, pick of the week, potw
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (26)
12 Jul 2013 Jonathan Lister

Clicking on one of the copied lines in the new figure causes the failure.

12 Jul 2013 Jonathan Lister

This is a great tool. I did find one bug. When a user exports a region to a new figure it appears that the copied lines retain the 'selected' callback and the 'update' case fails due to no cursors on the new plot. I fixed this issue by modifing the first few lines of the 'update' case to be:

case 'update' %Update the cursor value
%Find the position of the existing cursors

cursors = findobj(axh,'Tag','Cursor');

if isempty(cursors)
dualcursor('on',[],[],[],axh);
return
end

28 May 2013 Aditya

Great utility. I especially like how it is easy to right click and export the data.

Can this utility work with subplots and multiple lines within each subplot?

I run into this a lot when looking at test data obtained from DAQ hardware or even when looking at simulation results.

Have you considered incorporating this feature into a utility "ssc_explore" that Atul Suri from Mathworks created?

28 May 2013 Aditya  
13 Mar 2013 Danielle

flexible, useful and generic. Absolutely amazing!

19 Jan 2012 Preston

Would it be possible to expand callback functionality so that I could call it within a GUI whenever a cursor was moved?

29 Dec 2011 Francis

Another vote for horizontal cursors.

07 Nov 2011 fatanssi mohamed  
07 Nov 2011 fatanssi mohamed

I would like to thank you very much for this precious work. And I need to ask you how we can have an additionnaly horizontal dual cursor at the same time in the same plot
Sincerly your's

30 Sep 2011 rasam aliazizi  
30 Sep 2011 rasam aliazizi

was gga do that my self but hey now i have it, thanks....

08 Mar 2010 CĂ©dric DuchĂȘne

Thank you very much for this tool.

Is it possible to use this function on the horizontal axis ?
How do you think it should be difficult to add this ability to work in this case ? (Toogle mode vertical <--> horizontal)

Thank you again.

27 Oct 2009 Roy

If you have multiple plots in one figure how do you select which one to select?
Really nice work.

15 Apr 2009 Scott

Is it possible to have this function be "modal". For instance, if I wanted to use this function in a script that asks the user to set the lower and upper bounds of interest using dualcursor, how do I have my code stop and wait for the user to slide the vertical bars to the appropriate locations? I guess I need a button added to the plot so that the program waits until the limits are set before the user hits the "submit" button?

04 Apr 2009 Hoi Wong

It seems like the program doesn't like figures being a child of uipanel:

??? Error using ==> set
There is no 'WindowButtonDownFcn' property in the 'uipanel' class.

Error in ==> dualcursor at 688
set(get(axh,'Parent'),'WindowButtonDownFcn','','WindowButtonUpFcn','')

Error in ==> dualcursor at 220
dualcursor('off',[],[],[],axh);

Error in ==> episodesPanel>slider_strip_Callback at 147
dualcursor([1 2], handles.panel.episodes.infoDisplay.axes_electrogram);

??? Error while evaluating uicontrol Callback

??? Error using ==> uicontextmenu
An object of class uicontextmenu, can not be a child of class uipanel.

Error in ==> dualcursor at 325
cmenu = uicontextmenu('Parent',get(axh,'Parent'));

Error in ==> episodesPanel>slider_strip_Callback at 147
dualcursor([1 2], handles.panel.episodes.infoDisplay.axes_electrogram);

30 Jul 2008 nicolas billard

Excellent. Only 1 thing : When i compile a soft which calls dualcursor, it turns. But it canno't turn when i deploy the soft on target pc with matlab runtime. May be it's due to the crypto aspect of dualcursor which is again crypted by compilation. Is it a solution for it?

26 Apr 2005 Tony Rainoldi

works great

31 Mar 2005 Friedhelm Steinhilber

super!

20 Jul 2004 Alex Boboc

excelent

03 Aug 2003 Frank Hart

Not working for me. Shame, too, it could be so useful. I am using Matlab R11 (5.3), and
when I run the sample code and then call
dualcursor, I get this message back:

??? labelformatfcnh = @
|
Missing variable or function.

Syntax error in ==> C:\MATLAB_SR11\central\dualcursor.m
On line 147 ==> datalabelformatfcnh = @local_maketextstring;

26 Apr 2003 Paul Koola

Cool Tool

13 Mar 2003 thomas toth

my plot contains multiple data sets (used hold on). is there a way to set the cursors on two different graphs as data source?
eg. measure x/y difference between two points on two graphs (data) within the same plot. could maybe done using left/right click of mouse?

12 Mar 2003 thomas toth

Very nice tool. Just what I needed for my data evaluation and extraction. Now it's as good as any simulation tool. Thanks for the tool.

13 Jan 2003 Lisa Barker

Works great

26 Dec 2002 Poh Chee Khun

This is what I am looking for!

23 Dec 2002 Denis Gilbert

Neat program for interactive data exploration !

Updates
07 Jan 2003

Small bug fix: Eliminated error when user clicked on the figure background.

14 Mar 2003

Small bug fix: Eliminated error when clicking on a line AFTER dualcursor has been turned off. Thanks to Hao Fang for catching this.

06 Jun 2003

Small bug fix: Eliminated error when clicking on a line AFTER dualcursor has been turned off. Thanks to Hao Fang for catching this.

24 Oct 2007

Now works (hopefully) with plot types that create compound (hggroup) objects, such as stem. Thanks to Ralph Schmidt for pointing out the bug.

09 Sep 2009

Enhancement - now works when axes is parented to uipanel.

16 Sep 2009

Small fix - now works when the axes is parented to a uipanel, too (I wrote the original back in the day when the figure was the only parent an axes ever had ...)

21 Oct 2009

A few small updates based on user feedback.

28 Oct 2009

A few small feature requests.

21 Sep 2011

Removed hype from description.

Contact us