How to convert time into matlab system?

1 次查看(过去 30 天)
Hello everyone,
I have two columns A,B the first one ,A,contains a date (Year, Month and Day) while B contains hours and minutes. I want to create a third column C where I merge both columns. Initially, A and B were double so I used the next code to tranforme them to Matlab date system:
A = sp500_onemin(:,1)
d = datenum(num2str(A),'yyyymmdd')
date = datestr(d,20)
My first problem is when I tried to transform column B (composed by hours and minutes) and I used the nextc command, Matlab always gives me the same number in "time":
B = sp500_onemin(:,2)
t= num2str(B)
time= datenum(t,'HHMM')
Can someone please tell me where is my mistake?
After fixing this, how can I merge column A and B to have a new column compose by date and time?
Thanks a lot for your help!

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-4-23
A={'2000/02/15' '12:30';'2015/03/16' '18:55'}
b=arrayfun(@(x) strjoin(A(x,:)),(1:size(A,1))','un',0)
out=[A b]

更多回答(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