绘制数据与时钟时间 [英] Plotting data versus clock time

查看:135
本文介绍了绘制数据与时钟时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有高分辨率数据(500 Hz)。我从12:00:00开始。



总共我有720万个数据点< 7,200,000x1 double>被叫数据。如何实时绘制,如12点,1点,2点,3点,4点等(日期刻度)

解决方案

考虑这个例子:

  Fs = 500; %#采样频率(Hz)
startTime = datenum('12:00:00 PM','HH:MM:SS PM'); %#录制开始时间
x = cumsum(rand(7200000,1)-0.5); %#一些随机数据

t =(0:(numel(x)-1))./ Fs; %#时间(秒)
t = t / 3600/24 + startTime; %#时间(日期)

%#plot
plot(t(1:2000:结束),x(1:2000:结束))%#绘制每2000个值
datetick('x','HH:MM:SS PM')
xlabel('Time'),ylabel('Data')



日期轴刻度标记的格式化使用 DATETICK 功能。请阅读文档,了解如何自定义日期格式。



请注意,您有数百万点,我选择绘制子样本(每2000个值)但是如果你喜欢,你可以轻松地改变它来绘制整个数据。


I have high resolution data (500 Hz). I started at 12:00:00 p.m.

In total I have 7.2 million data points <7,200,000x1 double> called data. How would I plot it against real time, like 12 pm, 1 pm, 2 pm, 3 pm, 4 pm, etc. (date ticks)

解决方案

Consider this example:

Fs = 500;                                         %# sampling frequency (Hz)
startTime = datenum('12:00:00 PM','HH:MM:SS PM'); %# recording start time
x = cumsum(rand(7200000,1)-0.5);                  %# some random data

t = (0:(numel(x)-1)) ./ Fs;                       %# time in seconds
t = t/3600/24 + startTime;                        %# time in days (serial date)

%# plot
plot(t(1:2000:end), x(1:2000:end))                %# plot every 2000 values
datetick('x','HH:MM:SS PM')
xlabel('Time'), ylabel('Data')

The formatting of the date axis tick marks is done using the DATETICK function. Read the documentation to learn how to customize the date format.

Note that as you have millions of points, I opted to plot a sub-sample (every 2000 values), but you can easily change that to plot the entire data if you like...

这篇关于绘制数据与时钟时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆