% This matlab script reads in a 2D array containing time(sec), signal1, signal2
% It computes the FRF = Signal2(jw)/Signal1(jw) as the square root of the ratio of PSDs.
% PSDs are estimated using a burg approach, which is well suited for short
% duration, noisy signals which may be encountered during the E80 rocket
% flights.

nfft=8192;
[r,c] = size(data);
fs = 1/(data(2,1)-data(1,1));

disp('...computing psd estimates...')
for j=2:c
    
    [PSD,f]=pburg(data(:,j),order,nfft,fs);
    psd(:,j)=PSD;
    
end

psd(:,1)=f;        
   
% Compute the FRF magnitude as the square root of the ratio of PSDs.
FRF(:,1)=f;
FRF(:,2)=sqrt(psd(:,3)./psd(:,2));
