years read in as 18 instead of 2018; how do I add 2000 years?
Show older comments
I checked similar questions asked and it seems like the previous answers aren't quite what I am looking for. I have a csv file with a column of date and time. The dates are all mm/dd/18 not mm/dd/2018 so the years read into matlab as 18 not 2018. How can I add 2000 to the year in my timestamps (after importing to matlab). I tried using the addtodate function to add 2000 years (see below) but I got an error that says "Date number must be a numeric scalar." I'm not sure which value is my date number. I am sure there are several ways to do this. I am just looking for a straightforward way to save my year data correctly so that the matlab timestamps are correct. Thank you!
I have also attached the csv file here.
mba = readtable('2018_irradiance.csv');
irrad = mba.PAR;
timestamp = datenum(mba.PST);
times = addtodate(timestamp, 2000, 'year');
Accepted Answer
More Answers (0)
Categories
Find more on Dates and Time 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!