Rearrange time and turn it into Julian time

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Akira Agata
Akira Agata il 1 Dic 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 Commenti
nada
nada il 3 Dic 2019
the error i have
Undefined function 'datetime' for input arguments of type 'double'.
i have, Issuance matlab is R2014a
Akira Agata
Akira Agata il 3 Dic 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...

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by