Reputation: 1
Trying to do a spectral estimation but have a problem I'm not sure what the reason is, I'm also following this documentation as well https://www.scilab.org/product/man/pspect.html
I am trying to first get the fft of the filter with the white noise, my filter being a band pass
Fs=22050;
cf=[650 750]/Fs;
rand('normal');rand('seed',0);
x=rand(1:1024-33+1);
hn=iir(4,'bp','butt',cf,[0 0]);
h1=[hn 0*ones(1:max(size(x))-1)];
x1=[x 0*ones(1:max(size(hn))-1)];
hf=fft(h1,-1);
Problem comes when i try to do the fft, scilab tells me
--> hf=fft(h1,-1);
in builtin fftw
Function not defined for given argument type(s),
check arguments or define function %r_fftw for overloading.
I am not sure what the problem could be other than something is wrong with my filter but even then I am not aware what could be wrong, used it to filter some signal and it worked well.
Thank you very much.
Upvotes: 0
Views: 175
Reputation: 1010
You cannot apply the Fourier transform to a filter. The filter is represented by a rational polynomial function in the Laplace s-domain, and the Fourier transform takes in a function in the time domain as argument. As of the fft()
, it should be applied to a matrix containing the samples of your signal. If you want to see the behaviour of your filter over white noise, you should pass the signal to the filter, and use fft()
afterwards.
As for your code, iir()
returns the typed listed hn
containing a rational polynomial, which is the filter's transfer function. When you do
h1=[hn 0*ones(1:max(size(x))-1)];
you create a row matrix h1
in which the first element is the filter's transfer function. The second part 0*ones(1:max(size(x))-1)
simply creates a row matrix made of 991 zeros and append it to the first element. Since all elements in a matrix have to be of the same type, all these zeros become rational null polynomials. Such matrix is not acceptable as an input to fft()
.
If you want to quickly check if your filter works the way it is supposed to, instead of manually testing it with white noise, you could try using bode(hn)
to create a Bode plot, in which you can check its cut-off frequencies, amplitude responses and phase shifts.
Upvotes: 1