How datetime and integer or float value can co-habitate in an array?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Jan
2015년 6월 26일
The datetime "e" is a string already. So you have actually:
e = '05-Feb-2015 18:15:59'
with the quotes.
Walter Roberson
2015년 6월 26일
Keep in mind that datetime is a newer object class, and members of that class print out without quotes.
채택된 답변
Steven Lord
2015년 6월 26일
Use a cell array, as Azzi said, or use a table object.
x = 12345;
t = datetime('today');
A = table(x, t)
For a slightly larger table with some random data for today and the next 9 days:
x = randi(100, 10, 1);
t = datetime('today')+days((0:9).');
t.Format = 'dd-MMM-yyyy'; % Adjust the formatting of the dates to display only day, month, and year
A = table(x, t)
추가 답변 (1개)
Azzi Abdelmalek
2015년 6월 26일
편집: Azzi Abdelmalek
2015년 6월 26일
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
Jan
2015년 6월 26일
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?
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!