How to plot strings in an cell array as x axis.
이전 댓글 표시
Hello, I'm working on synchronising data from two different sources. Sample data from the two sources are timecoded in this format
HH:MM:SS.FFF
where the FFF is milliseconds.
It doesn't seem that this is some form of supported data format in Matlab(?) so I have the timeseries stored as strings in an cell array. The question is if it is possible to plot the data as a function of this cell array or if there is a smarter way to perform this.
Best regards.
답변 (2개)
Azzi Abdelmalek
2012년 12월 10일
This format is supported by Matlab
Example
datestr(now,'HH:MM:SS:FFF')
You can convert the time strings manually.
C = {'12:13:14.156', '12:13:16.157'}
n = numel(C);
S = sprintf('%s*', C{:});
N = sscanf(S, '%d:%d:%f*', [3, n]); % Or [n, 3] ?!
N = [zeros(n, 3), transpose(N);
DNum = datenum(N);
Another simpler but slower solution:
C2 = strcat({'10-Dec-2012 '}, C);
DNum = datenum(C2, 'dd-mmm-yyyy HH:MM:SS.FFF');
(I cannot test this currently.)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!