FFT for ideal filters

4 visualizzazioni (ultimi 30 giorni)
Anya ch
Anya ch il 5 Giu 2016
Modificato: Anya ch il 5 Giu 2016
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 !

Risposte (1)

Weird Rando
Weird Rando il 5 Giu 2016
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')

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by