MATLAB Examples

Analyze Signals with Inherent Time Information

Load a file that contains measurements of the international normalized ratio (INR) performed on a patient over a five-year period. The INR measures the effect of warfarin, a blood thinner used to treat people predisposed to clotting.

The file includes a datetime array with the date and time of each measurement, and a vector of INR readings. Display the first five time points.

load INR

Date(1:5)
ans = 

  5x1 datetime array

   05/15/09 11:28 AM
   06/16/09 09:05 AM
   07/02/09 09:50 AM
   07/16/09 11:20 AM
   07/31/09 12:05 PM

Convert the time readings to a duration array by subtracting the first time point. Convert the duration array to seconds.

t = Date-Date(1);
s = seconds(t);

Create a timetable with the duration array and the INR readings.

TT = timetable(t,INR);

Create a timeseries object with the time in seconds and the INR readings.

ts = timeseries(INR,s,'Name','inr');

Open Signal Analyzer. Under Display Grid, select three displays.

  1. Drag the timetable to the first display. The app calls this signal TT.INR.
  2. Drag the timeseries object to the second display. The app calls this signal ts.inr.
  3. Drag the array of INR readings to the third display. Add time information. Select the signal by clicking its legend. From the Analyzer tab, click Time Values. Select the Time Values option and in the Time Values field, enter t.