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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

질문:

2017년 8월 2일

댓글:

2017년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by