Designfilt and crossover filters?
Show older comments
Can anybody help me with an alternative function for DesignFilt and crossover filters. These functions work only with matlab 2016. it doesn't work in matlab 2013. What is the alternative function?
Accepted Answer
More Answers (2)
Darsana P M
on 17 Mar 2017
0 votes
10 Comments
Star Strider
on 17 Mar 2017
I no longer have access to R2013a. There should be no problem with the cell array assignments.
There could be differences in how the vectors are output. See if these changes work:
[z(:,k1),p(:,k1),k(k1)] = butter(7, [pf(k1) pf(k1+1)]/Fn);
[sos{k1},g{k1}] = zp2sos(z(:,k1),p(:,k1),k(k1));
It changes the row vectors to column vectors. This is a guess on my part as to how the R2013a butter (and other) functions format their outputs.
If that does not work, I am out of ideas.
Darsana P M
on 18 Mar 2017
Darsana P M
on 18 Mar 2017
Star Strider
on 18 Mar 2017
‘Wow that really worked!!!!!!!!! Thanks a lot.’
Thank you! My pleasure!
‘Which parameter should i change?’
I am not certain what you want. You cannot have any of the passbands or stopbands exactly at 0 or 1 (actually normalised frequencies of 0 or pi or 0 and your Nyquist frequency) because those are the limits of the frequency space for your sampled signal. You can get close to them (you have to experiment with your filters to determine how close you can get, depending on the other filter parameters) but you cannot by definition include them. (They are included by default in lowpass and highpass filters that do not specifically include them. You cannot specify filter band limits that include them.)
So if you want a filter that goes from (and includes) 0 Hz to the lower passband of your lowest bandpass filter, use a lowpass filter design with the passband approaching the lower passband of your lowest filter. If you want a filter that goes from the upper passband of your highest filter to the Nyquist frequency, use a highpass filter with the passband just above the upper passband of your highest filter. That is a long reply to a short question. I wanted to provide background.
You can definitely filter your audio signal. If it is a (Nx2) stereo matrix, filter it as you would filter any other signal. Both channels will be filtered at the same time, and the output will be a (Nx2) array of your filtered signal.
It is easiest to filter your signal through each filter in a loop similar to the way you created them. Use the filtfilt function to do the actual filtering.
Example code to do the filtering:
for k1 = 1:length(cf)
filt_sig{k1} = filtfilt(sos{k1}, g{k1}, sig);
end
where ‘sig’ is the signal you are filtering. I use a cell array for ‘filt_sig’ because I do not know anything about your signal. The cell array will work for ‘sig’ being either a vector or a matrix (for example an (Nx2) stereo sound signal). You can use a double array, and assign the output to the appropriate rows or columns, but here, the cell array is easier. It is easy to recover your filtered signal from the cell array. The filtered output signal will be in the cell array.
Darsana P M
on 18 Mar 2017
Star Strider
on 18 Mar 2017
My pleasure.
All you need to do is to supply a vector of band-edge frequencies that meet your requirements.
This will design 200 filters matching your requirements:
pf = [20 100:100:2E+4];
Note — The length (number of elements) in ‘pf’ must be odd. The length of this ‘pf’ vector is 201, so it will work.
Darsana P M
on 18 Mar 2017
Star Strider
on 18 Mar 2017
Yes, providing that your sampling frequency is at least 44.1 kHz (the standard audio sampling frequency). That gives enough frequency space on the high end (from 20 kHz to 22.05 kHz) to allow the highest filter to have a complete passband, including the transition region from the passband to stopband.
Darsana P M
on 19 Mar 2017
Star Strider
on 19 Mar 2017
My pleasure.
Darsana P M
on 22 Mar 2017
4 Comments
Darsana P M
on 22 Mar 2017
Star Strider
on 22 Mar 2017
As I mentioned before, your sampling frequency, ‘Fs’ is assumed to be the standard audio sampling frequency of 44100 Hz, giving a Nyquist frequency, ‘Fn’ of 22050 Hz. If you use that sampling frequency, you can design your filters with no problems.
You cannot design your filters with those passbands with a sampling frequency of 8200 Hz. It is simply not possible.
Darsana P M
on 24 Mar 2017
Star Strider
on 24 Mar 2017
My pleasure.
Categories
Find more on Measurements and Spatial Audio in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
