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 CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by