Rearrange time and turn it into Julian time

2 ビュー (過去 30 日間)
nada
nada 2019 年 12 月 1 日
コメント済み: Akira Agata 2019 年 12 月 3 日
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

採用された回答

Akira Agata
Akira Agata 2019 年 12 月 1 日
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 件のコメント
nada
nada 2019 年 12 月 3 日
the error i have
Undefined function 'datetime' for input arguments of type 'double'.
i have, Issuance matlab is R2014a
Akira Agata
Akira Agata 2019 年 12 月 3 日
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...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by