MATLAB: How to start the plot from the beginning of the x-axis

plot

Hi everyone,
I try to create a plot where I want to assign in the x-axis the dates, starting from 01:1974 to 12:2014. If I create the equivalent number of random variables, ie 492, and plot it, I get some emplty space at the beginning of the x-axis. The code is the following
time = datetime(1974,1:492,1);
y1 = randn(492,6);
y2 = randn(492,6);
figure;
k = 1 : 6;
a= 0 :5;
varnames_y1 ={'A ', 'B', 'C' , 'D' , 'E', 'F'}
for i = 1:6;
subplot(6,2,a(i)+ k(i))
filename = plot( time' , y1( : , i ) );
title ( varnames_y1(i));
hold on
end
varnames_y2 ={'G ', 'H', 'I' , 'J' , 'K', 'L'}
for i = 1:6;
subplot(6,2,a(i)+ k(i) + 1)
filename = plot( time' , y2( : , i ) );
title ( varnames_y2(i));
hold on
end
If you run it you will see that the dates instead of starting from 01:1974, start from 1969. Hence, I get empty space until 01:1974. I would appreciae any help. Thanks in advance.

Best Answer

clc; clear all ;
time = datetime(1974,1:492,1);
y1 = randn(492,6);
y2 = randn(492,6);
figure;
k = 1 : 6;
a= 0 :5;
varnames_y1 ={'A ', 'B', 'C' , 'D' , 'E', 'F'} ;
for i = 1:6;
subplot(6,2,a(i)+ k(i))
% filename = plot( time' , y1( : , i ) );
x = datenum(time) ;
filename = plot( x' , y1( : , i ) );
axis tight
datetick('x','mm:yyyy','keeplimits')
title ( varnames_y1(i));
hold on
end
varnames_y2 ={'G ', 'H', 'I' , 'J' , 'K', 'L'} ;
for i = 1:6;
subplot(6,2,a(i)+ k(i) + 1)
x = datenum(time) ;
filename = plot( x' , y2( : , i ) );
axis tight
datetick('x','mm:yyyy','keeplimits')
title ( varnames_y2(i));
hold on
end