Number to time of day conversion with datestr problem....
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi , I have an analysed data-set that I want to present the user.This data set has analysis for a time series data, therefore i have produced aggregated data for every 15 minutes.
Now since this has to be organised, i wanted to make colums of time periods of data that i want to illustrate. I used the following lines of code:
tp = 15/(24*60)
kilo = 1:(24*60/15);
l = datestr(kilo*tp,'HH:MM PM')
for first 5 points i get:::
l =
12:15 AM
12:30 AM
12:45 AM
1:00 AM
1:15 AM
Now the main problem is the accessibility with this new matrix l ..
%%%%%%%%%%%%%%%%
l(1:9)
ans =
111 2221
%%%%%%%%%%%%%%%%%
l(1)
ans =
1
%%%%%%%%%%%%
instead of the above answers i want l(1) to give me '12:15 AM' and not '1'
Thank you very much for your help in advance.
댓글 수: 0
채택된 답변
the cyclist
2011년 12월 19일
Your output "l" is a character array, of dimension 96x8. The first row of that array can be displayed with
>> l(1,:)
rather than
>> l(1)
which is only the first character.
The reason that l(1:9) gave the output that you saw is the MATLAB is pulling the first 9 characters going down the first column.
You could convert that character array to a 96x1 cell array, where each row will be put into one element of the cell array, using
>> timeCell = cellstr(l)
Then,
>> timeCell{1}
would be the entire first row. (Note the curly brackets in that last expression, which are used to access the contents of the cell, rather than the cell itself.)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!