FFT for ideal filters

조회 수: 2 (최근 30일)
Anya ch
Anya ch 2016년 6월 5일
편집: Anya ch 2016년 6월 5일
Hello everyone,
i have to plot impulse responses for some ideal filters (see the picture)
(lowpass highpass bandpass bandstop)
i was able to plot the lowpass one using this code :
if true
t=-5:.01:5;
x=rectpuls(t,2*0.2);
figure(1)
plot(t,x)
grid
Ts = mean(diff(t));
Fs = 1/Ts;
L = length(x);
ftx = fft(x)/L;
ftxs = fftshift(ftx);
Fv = linspace(-Fn, Fn, L);
figure(2)
plot(Fv, abs(ftxs))
grid
end
Now i want to do the rest, how can i do it ? thanks you !

답변 (1개)

Weird Rando
Weird Rando 2016년 6월 5일
You do realise that the diagram you uploaded is the impulse responses for the ideal filters.
All you need to do is create an array with 1's and 0's at certain points of a and b.
freq = -.5:0.01:.5;
%high pass
b = 0.2;
hp = ones(1,length(freq));
hp(abs(freq)<0.2) = 0;
plot(freq,hp);
%axis([-0.6 0.6 -1 2]);
xlabel('Frequency')
ylabel('Magnitude')

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by