How datetime and integer or float value can co-habitate in an array?
Mostrar comentarios más antiguos
I am trying to save both a float or integer value together with a datetime value in an array. Anyway of making both these values cohabitate in an array?
d= 5.5
e = 05-Feb-2015 18:15:59
f= [d e]
Of course this is an error. But I am trying to map integers values to a datetime value. How i can do this. Should i change the datetime to a string?
2 comentarios
Jan
el 26 de Jun. de 2015
The datetime "e" is a string already. So you have actually:
e = '05-Feb-2015 18:15:59'
with the quotes.
Walter Roberson
el 26 de Jun. de 2015
Keep in mind that datetime is a newer object class, and members of that class print out without quotes.
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 26 de Jun. de 2015
Editada: Azzi Abdelmalek
el 26 de Jun. de 2015
Use cell array
d= 5.5
e = '05-Feb-2015 18:15:59'
f= {d e}
or
d= 5.5
e =datenum( '05-Feb-2015 18:15:59')
f=[d e]
or use struct array
d= 5.5
e ='05-Feb-2015 18:15:59'
f.date=d
f.value=e
9 comentarios
yashvin
el 26 de Jun. de 2015
Azzi Abdelmalek
el 26 de Jun. de 2015
Editada: Azzi Abdelmalek
el 26 de Jun. de 2015
Have you read my answer? you can't write e=05-Feb-2015 18:15:59, it's
e ='05-Feb-2015 18:15:59'
Also, I said you can use cell arrays
array={'05-Feb-2015 18:14:23' '05-Feb-2015 18:14:27' '05-Feb-2015 18:14:31'}
d=5.5
e=array(1)
f={d e}
Azzi Abdelmalek
el 26 de Jun. de 2015
If you want to display it
f{1}
f{2}
Walter Roberson
el 26 de Jun. de 2015
Azzi probably meant
e = array{1}
rather than
e = array(1)
before the
f = {d e}
yashvin
el 26 de Jun. de 2015
Walter Roberson
el 26 de Jun. de 2015
t = datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss Z');
{t 3; t 5}
Jan
el 26 de Jun. de 2015
I do not understand this sentence:
My second query is that my inital datetime array is very long
(about 3000 in length)..how do i convert it automatically between commas?
yashvin
el 29 de Jun. de 2015
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!