フィルターのクリア

mirroring a magnitude response of a filter from -1 to 1

2 ビュー (過去 30 日間)
Aly Khafagy
Aly Khafagy 2022 年 5 月 7 日
回答済み: Paul 2022 年 5 月 7 日
This code shows the FIR filter magnitude response with the normalized frequency through interval from [0 to pi] in a figure, my question is how i can make mirroring of this magnitude response to start through interval from [-pi to pi] ??
clc;
close all;
clear all;
n1= 15; %order
Fs= 100; %sampling frequency
fc= Fs/4; %cutoff frequency
%nyq_f= Fs/2; %normalize cutoff frequency wrt to nyquist freq
%wn= fc/nyq_f; %normalized fc
wc= (2*pi*fc)/Fs;
wn= wc/pi;
%window= hamming(n+1)
H1= fir1(n1,wn,hamming(n1+1));
h1= freqz(H1); %frequency response
f1= linspace(0,Fs/2,512);
w1= (2*pi*f1)/Fs;
w= w1/pi;
plot (w, abs(h1))
axis([0 1 -0.1 1.1])

採用された回答

Jonas
Jonas 2022 年 5 月 7 日
編集済み: Jonas 2022 年 5 月 7 日
use
plot([-w(end:-1:2) w],abs([h1(end:-1:2); h1]))
i mirror only down to index 2 because index 1 is the 0 Hz component, which is already available before
  2 件のコメント
Aly Khafagy
Aly Khafagy 2022 年 5 月 7 日
thank you so much
Aly Khafagy
Aly Khafagy 2022 年 5 月 7 日
can you plot to me the impulse response of this halfband fir filter??

サインインしてコメントする。

その他の回答 (1 件)

Paul
Paul 2022 年 5 月 7 日
freqz() takes a third input that allows you to specify the frequency vector.
n1= 15; %order
Fs= 100; %sampling frequency
fc= Fs/4; %cutoff frequency
%nyq_f= Fs/2; %normalize cutoff frequency wrt to nyquist freq
%wn= fc/nyq_f; %normalized fc
wc= (2*pi*fc)/Fs;
wn= wc/pi;
%window= hamming(n+1)
H1= fir1(n1,wn,hamming(n1+1));
figure
freqz(H1);
wvec = linspace(-pi,pi,1024);
h1= freqz(H1,1,wvec); %frequency response
figure
plot (wvec, db(abs(h1))),grid
xlim([-pi pi])
ylim([-100 0])

カテゴリ

Help Center および File ExchangeDigital Filter Design についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by