adding a date column to a matrix

13 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2022-2-1
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?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by