designfilt error in loop
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
So I am using a total of 32 filters and trying to observe their cascaded outputs using the code below to design the bandpass filters. But I cant input filter_number 32 without getting the error included in the bottom. I thought by setting numFilts to 32 I could set filter_number from 0 to 32? Thank you for your time!
fs = 16e3;
numFilts = 32;
BW = 100; %Filter Bandwidth
filter_number = 30;
%range = [50 8000];
CenterFreqs = linspace(50, 8000, numFilts);
CF1 = CenterFreqs - BW/2; %Lower cutoff frequency
CF2 = CenterFreqs + BW/2; %Upper cutoff frequency
for ii = 1:filter_number
bpfilt{ii} = designfilt( ...
'bandpassfir', ...
'FilterOrder',20, ...
'CutoffFrequency1',CF1(ii+1), ...
'CutoffFrequency2',CF2(ii+1), ...
'SampleRate',fs);
end
[h{ii},f] = freqz(bpfilt{ii}.Coefficients,1,4*8192,fs); %4*8192 points, fir filt denom
Error (I do not have a line 189? I also didnt use the function parseAndDesignFilter, or is that what designfilt is?):
Error using designfilt>parseAndDesignFilter
Frequency specifications must be between 0 and 8000.
Error in designfilt (line 189)
[err,requestedResponse,parseParams,h] = parseAndDesignFilter(inputParamValueNames, varargin{:});
Error in test1 (line 13)
bpfilt{ii} = designfilt( ...
0 Commenti
Risposte (1)
Paul
il 25 Gen 2024
Modificato: Paul
il 25 Gen 2024
In this messsage "Error in designfilt (line 189)," the "line 189" is refering to the line number in designfilt, not your code. Your code had an error on line 13 of test1.m, which is the location of the call to designfilt.
Running the first part of your code:
fs = 16e3;
numFilts = 32;
BW = 100; %Filter Bandwidth
filter_number = 30;
%range = [50 8000];
CenterFreqs = linspace(50, 8000, numFilts);
CF1 = CenterFreqs - BW/2; %Lower cutoff frequency
CF2 = CenterFreqs + BW/2; %Upper cutoff frequency
Check the endpoints of CF1 and CF2
CF1(1)
CF2(end)
Now look at the error message:
"Frequency specifications must be between 0 and 8000."
I'm not sure if CF1(1) = 0 is considered to be "between 0 and 8000" but CF2(end) = 8050 is outside the allowable range in the error message.
Vedere anche
Categorie
Scopri di più su Digital Filter Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!