I implemented a sigal processing structure using very basic operation like multiply and add, I wonder is it possible to find a built-in function in matlab to treat this as a black box and obtain its frequency response. I imagine the process being:

  1. Feeding in windowed sinusoid with magnitude 1 at different frequency.
  2. Get output sinusoid fft at the corresponding frequency location and obtain magnitude and phase.
  • $\begingroup$ do you mean a ... matlab function? $\endgroup$ – Marcus Müller Dec 9 '20 at 9:24

The easiest would be to do an FFT of the impulse response. Something like this

%% calculating the transfer function of a time domain LTI model

% create an FFT grid
fftLength = 1024;
% make a unit impulse
diracDelta = zeros(fftLength,1); diracDelta (1) = 1;
% run your "black box" function, to create the impulse response
h = myFunction (diracDelta); % plus whatever arguments you need
transferFunction = fft(h);

You can certainly encapsulate this in a function but you need to pass in your black box function as a function handle and need to figure out how to manage additional arguments and state keeping (for filters with state). Given that the code above is so simple, it doesn't seem worth the bother.

Keep in mind that this ONLY works for LTI system. For anything else, the transfer function is undefined.

The choice of the FFT length is important: to avoid time domain aliasing it needs to be long enough to contain the entire impulse response or at least where it's decayed to "low enough".


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.