フィルターのクリア

Convert cell to time or double

3 ビュー (過去 30 日間)
Matt
Matt 2017 年 8 月 2 日
コメント済み: Matt 2017 年 8 月 2 日
I currently have a cell array filled with times like the below. I am trying to convert this into a usable format so that I can use the times in a plot. Does anyone know how I would do this? I have tried using str2double but this returns the values as NaNs. Someone also suggested that I used regexp but this resulted in the same outcome.
'000:00h:00min:23:743:990µs'
  2 件のコメント
José-Luis
José-Luis 2017 年 8 月 2 日
I don't understand the format. What's 23:743:990?
Matt
Matt 2017 年 8 月 2 日
000days:00hours:00min:23sec:743ms:990µs.
Does this make more sense?

サインインしてコメントする。

採用された回答

Jan
Jan 2017 年 8 月 2 日
編集済み: Jan 2017 年 8 月 2 日
Join the cell string to a string at first, then parse it by sscanf:
C = {'000:00h:00min:23:743:990µs', '000:00h:00min:23:743:990µs'};
S = sprintf('%s*', C{:});
V = sscanf(S, '%d:%dh:%dmin:%d:%d:%dµs*', [6, inf]);
  1 件のコメント
Matt
Matt 2017 年 8 月 2 日
Hi Jan, this is very close to what I would like to achieve, thanks. This currently lists each time as a column. My preferred output would be a single double for each time so as I can use it for the x axis on a plot. Is this possible?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by