Plotting data versus clock time

前端 未结 1 532
温柔的废话
温柔的废话 2021-01-23 15:02

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

1条回答
  •  死守一世寂寞
    2021-01-23 15:41

    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')
    

    screenshot

    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...

    0 讨论(0)
提交回复
热议问题