How to convert time into matlab system?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
angelavtc
le 23 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 23 Avr 2016
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!
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 23 Avr 2016
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 commentaires
Plus de réponses (0)
Voir également
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!