Rearrange time and turn it into Julian time

2 vues (au cours des 30 derniers jours)
nada
nada le 1 Déc 2019
Commenté : Akira Agata le 3 Déc 2019
Hi to all
I have data in file h172.csv
I write the code to open this
>clear
>load h172.csv
>[~, txt] = xlsread('h172.csv');
> JOPR_cells = regexp(txt(1:end),',', 'split');
>JOPR_cell =vertcat(JOPR_cells{:});
>JOPR = str2double(JOPR_cell);
>y = JOPR(:,1); % years
>m = JOPR(:,2); %months
>d = JOPR(:,3); %days
>h = JOPR(:,4); %hour
>sl = JOPR(:,5); %sea level (WL)
i want to rearrange history time like %formatOut = 'dd/mm/yyyy HH:MM:SS'; (Datatime) and in to Julian time (jday)
the table finaly example like this.
Picture1.png

Réponse acceptée

Akira Agata
Akira Agata le 1 Déc 2019
How about the following?
% Read the csv file
D = dlmread('h172.csv');
% Generate datetime vector
Time = datetime(D(:,1),D(:,2),D(:,3),D(:,4),0,0);
% Change display format
Time.Format = 'dd/MM/yyyy HH:mm:SS';
% Calculate julian date
Jday = juliandate(Time);
% Extract WL
WL = D(:,5);
% Arrange them to a table variable
T = table(Jday,Time,WL);
  2 commentaires
nada
nada le 3 Déc 2019
the error i have
Undefined function 'datetime' for input arguments of type 'double'.
i have, Issuance matlab is R2014a
Akira Agata
Akira Agata le 3 Déc 2019
Oh, that's because the function 'datetime' was introduced in R2014b.
A simple and better solution is to upgrade your MATLAB. Otherwise, we have to think about other solution...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by