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: 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" <slord@mathworks.com> wrote in message <j84a3g$1iu$1@newscl01ah.mathworks.com>...
>
>
> "Jesse Sipple" <jesse.sipple@tufts.edu> wrote in message
> news:j83u74$i2v$1@newscl01ah.mathworks.com...

> > 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
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


Here you go:

clear all
close all
clc

%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
time=start_date:step:end_date;

%make vector to run sine through
time_for_sine=1:length(time);

%create sine signal
sine=sin((2*pi*time_for_sine*5)/2000);

%---------
%plotting
%---------
figure(1)
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');

figure(2)
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]

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