# Matlab: is a highpass filter what I want, to obtain my required spectrogram? How do I design/apply this? (pic included)

The axes are wrong in the spectrogram. I have an audio wav file, and I know the sampling rate. this is read into the audioData variable. The audio is 1 channel. selected window length I believe (can't remember) is 512. I believe overlap is 50% ( the default?), 1024 fourier points. sampling rate is 250,000.

Using Matlab 2014a.

spectrogram made using this: s = spectrogram(audioData, 512, [], 1024, 250e3);

In the spectrogram, the bottom bit is near the 20kHz range and I want to get rid of this and concentrate on the thing at the centre (which is around 25khz). To my knowledge, I need a high pass filter to allow all of the frequencies above 20kHz. It seems like there are many ways to design filters which involve a lot of parameters and I'm a bit overwhelmed with how to start.

I essentially just want to cut out the bottom bit, so that I can image process the upper bit (ideally kept as close to intact, if not exactly, as possible)

If you don't have any specification for the filter besides the cut-off frequency, I believe the simplest way is to use the fir1 function. Note that the frequencies are normalised to half the sampling rate. For example:

b = fir1(n,20e3/(250e3/2),'high'); %Wn = Cutoff_req/(Fs/2)
figure; freqz(b,1,[],250e3); %visualize the filter if you wish
FilteredData = filter(b,1,audioData);


If you wish to have more control over the specifications (attenuation, ripple, etc.), I suggest using fdatool.

Your image dimensions are fine, they're just in terms of FFT bin index and window index rather than frequency and time (it's a simple conversion to get from A to B). It looks like a length 512 window (which is typically truncated to half that value - 256 - when looking at the power spectrum since its symmetric).

Sampling rate is probably NOT 250khz. For audio that would be... unusual. Since humans can't hear much above 15k, audio is typically sampled at 22.050khz, 44.1khz, or 48khz (Nyquist sampling requires a sample rate of 2x your highest signal frequency). I'm guessing your sample rate is probably 22050Hz.

Regardless of your sample rate though, you can design your filter based on normalized frequency in Matlab. Just eyeballing it, you want a normalized cutoff frequency of about 0.33. The higher the order of the filter, the more out-of-band suppression you'll get (you can characterize this with freqz as noted by previous poster).