%% Compute Difference Signal and Amplitude Spectrum of a TSA Signal
% In this example, sineWavePhaseMod.mat contains the data of a phase modulated sine wave. XT is a timetable with the sine wave data and rpm used is 60 RPM. The sine wave has a frequency of 32 Hz. To filter out the unmodulated sine wave and the sidebands of the phase modulating signal, use 32 as the orderList.
% Load the data and the required variables.

load('sineWavePhaseMod.mat','XT','rpm','orders')
head(XT,4)

% Note that the time values in XT are strictly increasing, equidistant, and finite.
%
% Compute the difference signal and its amplitude spectrum. Set the value of 'Domain' to 'frequency' since the orders are in Hz.

[Y,S] = tsadifference(XT,rpm,orders,'Domain','frequency')

% The output Y is a timetable that contains the difference signal, while S is a vector that contains the amplitude spectrum of the difference signal Y.
% Copyright 2018 The MathWorks, Inc.
%
%
%