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

New to MATLAB?

Plot empties after using datetick

Asked by Mohammad

Mohammad (view profile)

on 5 Apr 2013
Accepted Answer by bym

bym (view profile)

I am trying to use datetick method to label one of the axes i have but when i use datetick, the ticks are displayed properly, but the plot area is cleared and plot vanishes. Here is a simplified example of what i am trying to do:

    plot(rand(10));
    startDate = datenum('01-01-2009');
    endDate = datenum('12-31-2009');
    xData = linspace(startDate,endDate,5);
    set(gca,'XTick',xData);
    datetick('x','dd-mmm','keepticks');

Any suggestions?

Thanks

0 Comments

Mohammad

Mohammad (view profile)

Products

1 Answer

Answer by bym

bym (view profile)

on 5 Apr 2013
Accepted answer
clc;clear; close all
startDate = datenum('01-01-2009');
endDate = datenum('12-31-2009');
xData = linspace(startDate,endDate,10);% changed to match size of data
plot(xData,rand(10));
%set(gca,'XTick',xData);  %maybe not necessary?
datetick('x','dd-mmm','keepticks');

0 Comments

bym

bym (view profile)

Contact us