FFT for ideal filters

6 ビュー (過去 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 Center および File ExchangeDigital Filter Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by