Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Pairing two different values on one plot
Replies: 19   Last Post: Apr 18, 2013 2:44 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
PK

Posts: 7
Registered: 4/15/13
Re: Pairing two different values on one plot
Posted: Apr 16, 2013 9:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

dpb <none@non.net> wrote in message <kkjmtn$6fo$1@speranza.aioe.org>...
> On 4/16/2013 8:51 AM, Steven_Lord wrote:
> > "dpb" <none@non.net> wrote in message
> > news:kkji6t$nub$1@speranza.aioe.org...

> >> On 4/16/2013 12:52 AM, PK wrote:
> >> ...
> >>

> >>> now I managed to get dates on x axis but it only shows the date not the
> >>> time. and the cursot tip still shows the number 7.~+005 with my data.

> >>
> >> doc datetick % specify format you want
> >>
> >> As for the cursor, don't know--there's a good possibility TMW hasn't
> >> implemented the conversion back to a date string from the datenum.
> >>
> >> doc datestr % to convert back
> >>
> >> Best I know is a callback routine that incorporates it but never tried
> >> it...

> >
> > You can specify a custom display function for use by data cursors.
> >
> > http://www.mathworks.com/help/matlab/ref/datacursormode.html
> >
> > See the second half of the Example for how to specify the UpdateFcn.
> > Instead of using NUM2STR as the Example does, you'd use DATESTR.

>
>


Not sure I have understood fully..But here is my code

ts=strvcat(Timedata{1});
dn=datenum(ts(:,1:12),'yyyymmddHHMM');
datestr(dn)

plot(dn,mydata{29});
dcm_obj = datacursormode(figure);
set(dcm_obj,'UpdateFcn',@myupdatefcn)
set(gca,'XtickL',ts);

In addition I have my updatefcn.m in my matlab directory as below..

function txt = myupdatefcn(empt,event_obj)
% Customizes text of data tips

pos = get(event_obj,'Position');
txt = {['Time: ',datestr(pos(1))],...
['Amplitude: ',datestr(pos(2))]};

the o/p is the same graph with timestamp on x axis and data on y with data tip a number and data instead time and data.
thanks



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.