How do i get Char into Double

조회 수: 2 (최근 30일)
Jelthe
Jelthe 2016년 3월 31일
댓글: Image Analyst 2016년 3월 31일
Hello,
Does anyone know how i get timeinformation saved as a char into a double? I want to plot something over a time (HH:MM:SS) i got the information as a Workspace variable but as a class. I need it as an double to plot it.
thanks

답변 (2개)

Image Analyst
Image Analyst 2016년 3월 31일
Use datenum(). From the help:
format long
t = [datetime('now');datetime('tomorrow')]
DateNumber = datenum(t)
t =
07-Jan-2016 15:42:14
08-Jan-2016 00:00:00
DateNumber =
1.0e+05 *
7.363366543368312
7.363370000000000
  댓글 수: 2
Jelthe
Jelthe 2016년 3월 31일
Ok so i do have the timeinformation in decimalform then. How do i get it back into timeform when i plot it? so that the x-axes says 16:40 ....
Image Analyst
Image Analyst 2016년 3월 31일
You can make the tick marks whatever list of strings you want:
ax = gca;
ax.XTickLabel = yourCellArrayOfTimeStrings;
Example from the help:
ax.XTickLabel = {'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'};

댓글을 달려면 로그인하십시오.


Ilham Hardy
Ilham Hardy 2016년 3월 31일
Maybe this will help? str2num

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by