The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problem with trying to get tight xlim when using time data
Replies: 4   Last Post: Oct 24, 2011 3:17 PM

Advanced Search

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

Posts: 8
Registered: 7/21/11
Re: Problem with trying to get tight xlim when using time data
Posted: Oct 24, 2011 3:05 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Steven_Lord" <> wrote in message <j84a3g$1iu$>...
> "Jesse Sipple" <> wrote in message
> news:j83u74$i2v$

> > I'm trying to plot just a very small portion of time history data, about 5
> > seconds worth. I have it plotting fine for a larger range, I'm using
> > MATLAB time and it displays it no problem.
> >
> > The problem I'm getting is that it seems like it will only let the limits
> > of the x-axis go to about 10 seconds, so anything less than that does not
> > work. Any hints? Is there something different than MATLAB time that
> > works better for this?

> time = 0:0.1:10;
> y = sin(time);
> plot(time, y);
> xlim([1 1.1])
> This works fine for me. Can you show the code you're running where it
> doesn't appear that MATLAB will allow the limits of the X axes to be less
> than 10 seconds apart?
> --
> Steve Lord
> To contact Technical Support use the Contact Us link on

Here you go:

clear all
close all

%beginning and end date
start_date=datenum('25-Sep-2011 09:35:05');
end_date=datenum('25-Sep-2011 09:38:05');

%say sampling rate is 2000Hz
step=datenum('25-Sep-2011 09:35:05.0005')-datenum('25-Sep-2011 09:35:05');

%make vector for time to plot on

%make vector to run sine through

%create sine signal

plot(time,sine), datetick('x',13,'keeplimits'), grid on %this works fine

%now try to zoom in on a 2 second window
zoom1=datenum('25-Sep-2011 09:35:07');
zoom2=datenum('25-Sep-2011 09:35:09');

plot(time,sine), xlim([zoom1 zoom2]),...
datetick('x',13,'keeplimits'), grid on,...
%this does not zoom in, the limits should read 9:35:07 and 9:35:09

I also tried to manually zoom to a tighter window (in the plot window) and that did not work either. Thanks for looking into this!

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.