I'm trying to find the system transfer function of a set of input-output data using the FFT method. The algorithm I'm following is as follows:
- Load the input data and output data into matlab.
- FFT the input data and output data.
- Divide the output FFT by the input FFT and take the magnitude. Since the input for our example is a unit impulse, the input FFT is 1.0.
- Plot the result as a Bode' plot.
- Treat the resulting Bode' plot as a frequency response - which it really is - and use frequency response methods to fit a transfer function to the calculated Bode' plot.
My code is:
load testdata.mat; // testdata is a 2 column matrix (1001x2 matrix)
input = fft(signal(:,1)); // FFT of input data (1001x1 complex matrix)
output = fft(signal(:,2)); // FFT of output data (1001x1 complex matrix)
fft_ratio = output/input; // (1001x1001 complex matrix)
fft_ratio_mag = abs(fft_ratio); // (1001x1001 matrix) except column 1, all other columns have '0' data
bode(fft_ratio_mag(:,1))
I get the following error:
Error using bode (line 84)
Not enough input arguments.
Please guide me how to go about steps 4 and 5 in the above algorithm.