adding a date column to a matrix

7 views (last 30 days)
haveing the followoing matrix
EDP = [double(netcdf.getVar(ncid,0)),double(netcdf.getVar(ncid,1)),double(netcdf.getVar(ncid,2)),double(netcdf.getVar(ncid,3)),double(netcdf.getVar(ncid,4)),double(netcdf.getVar(ncid,5))];
%[Height, Latitude, Longitude, Azimuth, TEC, Ne]
and the following date corresponding to this matrix
EDPdate= datetime(Year, Month, Day, Hour, Min, 0,'TimeZone','UTC','Format', 'uuuuMMddHHmm');
EDPdate.TimeZone='America/Lima';
how I can add a new column to the matrix and store in it this date value, for all the rows.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Feb 2022
You cannot do that.
The double() present in the first expression shows that EDP is an array of double precision numbers. The datetime() in EDPdate, reinforced with setting the TimeZone, shows that EDPdate is desired to be a datetime object. However it is not possible to store a datetime object in a double array .
You could convert the datetime object to a serial date number, which would potentially lose precision, and would certainly lose the timezone.
Have you considered changing from using an array to using a table() object?

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!