MATLAB: How to set Time Axis

time axis

Hi Folks
I have a data in which time axis set in following format
ncdisp('myfile.nc')
time
Size: 39x1
Dimensions: time
Datatype: single
Attributes:
standard_name = 'time'
long_name = 'time'
units = 'months since 1970-01-01 00:00:00'
axis = 'T'
climatology = 'climatology_bounds'
year=ncread('myfile.nc','time')
year=
9×1 single column vector
6
18
30
42
54
66
78
90
102
114
126
138
150
162
174
186
198
210
222
234
246
258
270
282
294
306
318
330
342
354
366
378
390
402
414
426
438
450
462
But i want to convert variable year(6,18,30,…,462) to year(1:39), which represent 1 as 1970 and 39 as 2008;
I mean
year(1)=1970
year(2)=1971
.
.
.
year(39)=2008
Could you please suggest me, how can I make it ?
Thanks in advance

Best Answer

ncmon = ncread('myfile.nc','time');
year = 1970 + floor((ncmon - 1) / 12);