MATLAB: Need to generate bandpass filtered white-noise

bandpassfiltersoundwhite noise

Hi guys,
I am doing a psychophysical experiment and I need to generate two white noises, but which are bandpass filtered, the band of one shifted slightly higher than the other, so that the subjects can recognise the two sounds. The length needs to be 3s, fs of 44100 Hz.
I can generate the noise easily with the wgn function, but I am unable to bandpass filter it. Can someone please help me out?
Thanks

Best Answer

You will need to determine the spec of your filter and then create the filter. It looks like you are dealing with audios so I'll just use 20-20k Hz as an example. You can generate the filter like this.
fs = 44100;
hf = design(fdesign.bandpass('N,F3dB1,F3dB2',10,20,20e3,fs));
This creates a bandpass filter with pass band between 20 Hz and 20 kHz. You may or may not want this configuration so you may want to take a look at the help
doc fdesign.bandpass
Once you get the filter, assuming x is what you get from wgn, which is white noise, you can simply get the filtered noise by
y = filter(hf,x)
HTH