简体   繁体   English

matlab将毫秒转换为日期格式并绘制为x轴

[英]matlab convert milliseconds to date format and plot as x-axis

I am new to matlab. 我是Matlab的新手。 What I am trying to do is to plot the data I recorded from the phone on matlab. 我要做的是在Matlab上绘制从手机记录的数据。 The data is looks like this {timestamp, value}. 数据看起来像这个{timestamp,value}。

The timestamp is recorded in millionseconds by calling the Java function System.currentTimeMillis(). 通过调用Java函数System.currentTimeMillis(),以百万秒为单位记录时间戳。 Therefore I have two questions actually to plot it on matlab. 因此,实际上有两个问题要在matlab上绘制。

  1. How can I transform the timestamp from milliseconds to date format on matlab? 如何在Matlab上将时间戳从毫秒转换为日期格式?

  2. How can I plot the data on matlab, where Y-axis is the value, and X-axis is the date? 如何在Matlab上绘制数据,其中Y轴为值,X轴为日期? The graph should look like discrete dots. 该图应看起来像离散点。

Thanks a lot. 非常感谢。

To create plots with dates / times on one axis, plot your data, then relabel the axis using datetick 要在一个轴上创建具有日期/时间的图,请绘制数据,然后使用datetick重新标记轴

plot(datenum('1-jan-2000'):datenum('10-jan-2000'),[1:10])
datetick('x','dd-mm')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM