%% Frequency-RPM Map of Helicopter Vibration Data
% Analyze simulated data from an accelerometer placed in the cockpit of a helicopter.
% Load the helicopter data. The vibrational measurements, vib, are sampled at a rate of 500 Hz for 10 seconds. Inspection of the data reveals that it has a linear trend. Remove the trend to prevent it from degrading the quality of the frequency estimation.

load('helidata.mat')

vib = detrend(vib);

%
% Plot the nonlinear RPM profile. The rotor runs up until it reaches a maximum rotational speed of about 27,600 revolutions per minute and then coasts down.

plot(t,rpm)
xlabel('Time (s)')
ylabel('RPM')

%
% Compute the frequency-RPM map. Specify a resolution bandwidth of 2.5 Hz.

[map,freq,rpmOut,time] = rpmfreqmap(vib,fs,rpm,2.5);

%
% Visualize the map.

imagesc(time,freq,map)
ax = gca;
ax.YDir = 'normal';
xlabel('Time (s)')
ylabel('Frequency (Hz)')

%
% Repeat the computation using a finer resolution bandwidth. Plot the map using the built-in functionality of rpmfreqmap. The gain in frequency resolution comes at the expense of time resolution.

rpmfreqmap(vib,fs,rpm,1.5);

% Copyright 2015 The MathWorks, Inc.