필터 지우기
필터 지우기

Switching to datetime / numeric axis and returning datetime data points

조회 수: 1 (최근 30일)
Sjouke Rinsma
Sjouke Rinsma 2019년 11월 26일
댓글: Eric Delgado 2021년 2월 6일
Dear all,
I have an interface in which a user can graph data. Since I'm working with timetables, when using 'Time' (datetime variable) as X-variable, the axis ruler style automatically changes to a DatetimeRuler. However, in some cases it is preferable to use another (numeric) variable for the X-axis. The problem I face is that after having used the datetime variable 'Time' it does not seem possible to change back to a numericRuler. I've come across several posts on the topic (including this one) but so far I'm unable to revert the axis back to a numeric, and having to close the program and load all data again clearly is undesirable. By the way, I'm not using the 'hold on' function during all this.
Additionally, in the same program I use datacursormode to 'getCursorInfo' to return the datatip information, see e.g. the figure below. The Position result from these data points is:
[0.396209722222222, 100.120000000000]
[0.431294560315167, 20.0400000000000]
[0.458508101851852, 99.9600000000000]
of which the X-data can be converted to a string using datestr, but in this case the date-information is gone (e.g. " ans = '11:00 AM' "). I would have expected an absolute Matlab time value such as "7.375584585081019e+05" or comparable. When using data which covers more than one day the results get even less logical. Though there is also a 'DataIndex' value returned with the cursor_info which can be used to get the actual datetime from the original variable this of course is not really an elegant solution.
Hope anybody can shed some light on working with a datetime ruler. I'm using Matlab2017a by the way.
Thanks!
  댓글 수: 4
Nikolaus Koopmann
Nikolaus Koopmann 2020년 4월 17일
found it!
hint
num2ruler(evdata.IntersectionPoint(1), ax.XAxis)
Eric Delgado
Eric Delgado 2021년 2월 6일
I am having the same issue... And I couldn't find a solution using num2ruler or ruler2num functions to convert a DateTimeRuler axes into a NumericRuler axes. Hey @Nikolaus Koopmann, is it possible to use this function to change the ruler of the axes?!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by