how do I use datetick for this code?

1 view (last 30 days)
A = textscan(fopen('7633_Flux_AmeriFluxFormat_3.dat'),'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %f %f %f %f %f %f %f %f', 'Delimiter',',','Headerlines',1);
A_time = A{1,1};
B_time = num2str(A_time);
x_serial = datenum(B_time,'yyyymmddHHMM');
x = datetick('x','dd-mmm-yyyy HH:MM:SS','keeplimits')
CO2 = A{1,3};
figure()
plot(x,CO2)
this is the first part of my code. my x-axis is currently in matlab serial numbers. When I try running this, it says there are too many output arguments in the datetick line. I've never used datetick before. Please tell me what i'm doing wrong and how to fix it

Accepted Answer

Star Strider
Star Strider on 23 Sep 2018
I would code it differently:
fidi = fopen('7633_Flux_AmeriFluxFormat_3.dat');
A = textscan(fidi,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %f %f %f %f %f %f %f %f', 'Delimiter',',','Headerlines',1);
fclose(fidi);
A_time = A{1,1};
B_time = num2str(A_time);
x_serial = datenum(B_time,'yyyymmddHHMM');
CO2 = A{1,3};
figure()
plot(x,CO2)
datetick('x','dd-mmm-yyyy HH:MM:SS','keeplimits')
I do not have your file, so I am stating that this is*_UNTESTED CODE_*. You will have to see if it works.
  4 Comments
Susan Santiago
Susan Santiago on 23 Sep 2018
that did it! Thanks for your help!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!