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!