0

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:

  1. Load the input data and output data into matlab.
  2. FFT the input data and output data.
  3. 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.
  4. Plot the result as a Bode' plot.
  5. 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.

4
  • fft_ratio as a 1001x1001 matrix; does that sound right? Commented Oct 17, 2013 at 18:40
  • 1
    If this is the mathworks bode function, it works on system objects, not on matrices. mathworks.com/help/ident/ref/bode.html Commented Oct 17, 2013 at 18:43
  • Except the first column, all other columns are 0 + 0i. So it doesn't really matter I guess. I have seen the page mathworks.in/help/ident/ref/bode.html . But, I'm not able to generate the sys. Commented Oct 17, 2013 at 18:45
  • Don't use that function at all, see my answer. Commented Oct 17, 2013 at 19:45

1 Answer 1

1

Use element-wise divide, not matrix divide, and plot using the plot function. To produce a plot similar to that shown in the bode function you can plot using semilogx but do the dB and degree conversions yourself:

fft_ratio = output ./ input % note the dot
subplot(2,1,1)
semilogx(20*log10(abs(fft_ratio)))
subplot(2,1,2)
semilogx(plot((180/pi)*angle(fft_ratio))

Generate the x-axis using however you like, I usually use normalized radian frequency from 0 to 1, which is just linspace(0,1,length(fft_ratio)).

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, but how do I find the transfer function from this?
I'm not sure what "frequency response methods" are, but curve fitting is curve fitting regardless of the nature of the curve, and there are lots of ways to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.