i have to following code:
clc
clear all
close all
Fs = 6000; % Sampling frequency
T = 1/Fs; % Sample time
N=512; % Length of signal
t = (0:N-1)*T; % Time vector
% Sum of a 1kHz sinusoid and a 2.5kHz sinusoid
x1=4*sin(2*pi*1000*t);
x2=sin(2*pi*2500*t);
figure
subplot(3,1,3)
stem(t,x1);
figure
subplot(2,1,1)
stem(t,x2);
x=x1+x2;
y=fft(x);
fx=(-N/2:(N/2-1))*(Fs/N);
figure, plot(fx,abs(fftshift(y)));
i want to see the low part of the signal which means one impulse in the frequency domain, i am using this filter:
fc = 1500;
Wn = (2/Fs)*fc;
b = fir1(20,Wn,'low',kaiser(21,3));
fvtool(b,1,'Fs',Fs)
z = filter(b,1,y);
plot(t(1:100),abs(z(1:100)))
xlabel('Time (s)')
ylabel('Amplitude')
but i am seeing a periodic signal , how can i see the one impulse that is in the low frequencies?
You should use
z = filter(b,1,x);
,It's more common to plot only the positive frequencies.
Your
N
is already a power of 2 but I definedNFFT
in caseN
changes.BTW you don't need to use
figure
before eachplot
.