Is there a way to extract the numeric data from these chars?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi folks,
I have a cell of times (attached), which I need to read as numbers. Is there any way to do this?
Using num2str() doesn't work!
Thanks!
댓글 수: 0
채택된 답변
Mathieu NOE
2022년 1월 25일
hello
you can do that (will simply combine minutes and seconds into only seconds time vector)
but as your original data has resolution of 1 second only and many duplicates, so will the resulting time vector.
you must improve the time resolution of your data
load('time.mat')
tmp = str2double(split(Time,':'));
time_seconds = tmp(:,1)*60 + tmp(:,2);
댓글 수: 0
추가 답변 (1개)
Harry
2022년 1월 25일
편집: Harry
2022년 1월 25일
The data inside of Time variable are in time format like mm:ss. You can use datetime to extract them.
new_T = datetime(Time(1:end),'InputFormat','mm:ss','Format','mm:ss')
timeDuration = new_T-new_T(1);
timeDuration_inSeconds = seconds(timeDuration)
timeDuration_inMintues = minutes(timeDuration)
I hope, it works for you.
Note: num2str() will convert number to string. The output will not be number.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!