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

%
% 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.
% Drag the timetable to the first display. The app calls this signal TT.INR.
% Drag the timeseries object to the second display. The app calls this signal ts.inr.
% 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.
%
% Copyright 2012 The MathWorks, Inc.