%decayEnvelope uses a low pass filter of a squared signal to extract the
%decay envelope. It takes the inputted data and outputs the decay envelope

function [envData] = decayEnvelope(dataIn,n,cutoff3dB)

%configure the filter
d = fdesign.lowpass('N,Fc',5,600/10000);
Hd = design(d,'butter');
%square the data and multiply by two
dataIn = 2*(dataIn.^2);

%filter data 
envData = sqrt(filter(Hd, dataIn));
end