designfilt error in loop
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Paul
2024-1-25
编辑:Paul
2024-1-25
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specialized Power Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!