designfilt error in loop

조회 수: 8 (최근 30일)
S
S 2024년 1월 24일
댓글: S 2024년 1월 25일
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( ...

답변 (1개)

Paul
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)
ans = 0
CF2(end)
ans = 8050
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.
  댓글 수: 1
S
S 2024년 1월 25일
So would I change the range to fix this do you think? Or is my CF1 and CF2 the issue?
I tried making the range 8050 instead of 8000, but I got the same issue, Im thinking becuase now CF2(end) would now be 8100
I'm not sure how else I could fix this

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by