user2118915
user2118915

Reputation: 532

datetick too many output arguments

I have a time-series containing 900 entries, stored in a 900x2 matrix (first column are datenumbers converted from excel e.g. 732994 to represent 13-nov-2006, second column is the reading at each day) I would like to plot them out with the years marked out on the x-axis, using the datestr function.

here is my code segment.

x=newsgdata(:,1);
x=num2str(x); %converts datenumbers from int to string
dateline=datetick('x','yyyy');
plot(dateline,newsgdata(:,2))

when i run this code, i get the error: Error using datetick Too many output arguments.

I have tried running plot(datetick('x','yyyy'),newsgdata(:,2)) but the same error keeps popping up.

Upvotes: 0

Views: 444

Answers (1)

Peter
Peter

Reputation: 14947

First, plot vs the datenum directly:

plot(newsgdata(:,1), newsgdata(:,2));

Then, use datetick to convert the labels from datenums to strings.

datetick('x', 'yyyy')

Upvotes: 1

Related Questions