change datatype of x axes
15 次查看(过去 30 天)
显示 更早的评论
Hi, i made a GUI where i can plot some data. I can plot my data over numeric values (runtime of my experiment) or datetime values (date of my experiment).
So i can switch between these two modes: Datetime and Runtime
My Problem: when i plotted my data over Datetime and then switch to runtime and want to plot my data i get the following error:
Error using Sondenvergleich_CA_FA>ButtonPreview_Callback (line 280)
Values plotted against x-axis must be datetime values. To create datetime values, use the DATETIME function.
So it seems like my x-axis expects some datetime values but in runtime mode i give numeric values to my axis.
how can i get my xaxis to show numeric values again?
0 个评论
采纳的回答
dpb
2019-10-15
Axes are not polymorphic--they require a given data type.
You'll have to create two axes and select which to display depending upon which type of data is to be displayed.
If you need both simultaneously, you'll have to have two x axes on the same figure or use two figures.
Inviolate rule.
The only (crude and not recommended) way around would be to use the venerable datenum instead of datetime class. datenum is just a double camoflauged as a date; to make the axis represent dates one has to use the deprecated and klunky datetick function. As noted, NOT recommending this, but it is a way to put either on the same axis.
2 个评论
dpb
2019-10-16
Just the way TMW implemented the datetimeruler object internals -- it doesn't have the ability to switch back to normal double and regular axes object with internal callback routines once it is in place.
Not that they couldn't have done, but I suppose it never came to them that somebody would want to do so...
One can always submit an enhancement request with an example use such as yours as to why it should be possible.
更多回答(1 个)
Ranzige Erdnuss
2020-8-5
for me
cla(app.UIAxes,'reset')
made it possible to plot double values after I plotted some datetime values. After this command you must reset the axis labels again via:
xlabel(app.UIAxes, 'X Label')
ylabel(app.UIAxes, 'Y Label')
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!