How to plot strings in an cell array as x axis.
Afficher commentaires plus anciens
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.
Réponses (2)
Azzi Abdelmalek
le 10 Déc 2012
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.)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!