%% RPM Profile of Vibration Signal
% Generate a vibration signal with three harmonic components. The signal is
% sampled at 1 kHz for 16 seconds. The signal's instantaneous frequency
% resembles the runup and coastdown of an engine. Compute the instantaneous
% phase by integrating the frequency using the trapezoidal rule.

fs = 1000;
t = 0:1/fs:16;

ifq = 20 + t.^6.*exp(-t);
phi = 2*pi*cumtrapz(t,ifq);

%%
% The harmonic components of the signal correspond to orders 1, 2, and 3.
% The order-2 sinusoid has twice the amplitude of the others.

ol = [1 2 3];
amp = [5 10 5];

vib = amp*cos(ol'.*phi);

%%
% Extract and visualize the RPM profile of the signal using a point on the
% order-2 ridge.

time = 3;
order = 2;
p = [time order*ifq(t==time)];

rpmtrack(vib,fs,order,p)

%% 
% Copyright 2012 The MathWorks, Inc.