How can I plot the magnitude spectrum for these three filters?
조회 수: 9 (최근 30일)
이전 댓글 표시
%Low-pass Filter
B_lp = designfilt('lowpassfir', 'FilterOrder', 64, 'CutoffFrequency', 3e3, 'SampleRate', fs);
[b, a] = tf(B_lp);
x_lp = filter(B_lp, x);
%band-pass Filter
B_bp = designfilt('bandpassfir', 'FilterOrder', 64, 'CutoffFrequency1', 2000,'CutoffFrequency2', 5000, 'SampleRate', fs);
[b, a] = tf(B_bp);
x_bp = filter(B_bp, x);
%Low-pass Filter
B_hp = designfilt('highpassfir', 'FilterOrder', 64, 'CutoffFrequency', 4e3, 'SampleRate', fs);
[b, a] = tf(B_hp);
x_hp = filter(B_hp, x);
댓글 수: 0
답변 (1개)
Ganesh
2024년 6월 12일
Hi Faisal,
To plot the magnitude spectrum for the low-pass, band-pass, and high-pass filters you've designed, you can use MATLAB's "freqz" function, which computes and plots the frequency response of a filter. You may use the following documentation to learn more on the "freqz" function:
The freqz function is used without specifying the number of points to use for the frequency response, which means the default setting is used for a detailed plot. The "fs" parameter is provided to scale the frequency axis according to your sampling frequency, allowing you to view the frequency response in Hz.
Note that this approach visualizes the filter characteristics themselves, not the spectrum of the filtered signal. If you're interested in the spectrum of the filtered signal (x_lp, x_bp, x_hp), you would need to use a different method, like performing a Fast Fourier Transform (FFT) on the filtered signals.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!