DSPRelated.com
Forums

Re: Lowpass filter design [2 Attachments]

Started by aziz yemen May 31, 2010
HERE IS THE CODE WITH SAMPLE FILE  ANC COMPARING BETWEEN THE FILTERED AND  NOISY SIGNAL 
YOU CAN REMOVE WHATEVER IS NOT NECESSARY
 

[Yo,FS,NBITS1]=WAVREAD('1o.wav'); % read original signal
[Yn,FS,NBITS2]=WAVREAD('1n.wav'); % read corrupted signal
n1 =length(Yo);%Obtain the length of the original signal
n2 =length(Yn);%Obtain the length of the corrupted signal

% Time Domain Plot
figure(1)
subplot(2,1,1),plot((1:n1)/FS,Yo);
xlabel('Time(Second)');ylabel('Amplitude');
title('(Original):1041110990');
subplot(2,1,2),plot((1:n2)/FS,Yn);
xlabel('Time(Second)');;ylabel('Amplitude');
title('(Noisy):1041110990');

% playing the sound of the Orgingal and Noisy signals
soundsc(Yo);
soundsc(Yn);

% Frequency Domain Plot
N1=n1;
N2=n2;

Sot(Yo); %use FFT to transform original signal into frequency domain
Snt(Yn); %use FFT to transform noisy signal into frequency domain
f1=(0:((N1/2)-1))/(N1/2)*(FS/2); %define freq. up to 1/2 sampling rate
f2=(0:((N2/2)-1))/(N2/2)*(FS/2); %define freq. up to 1/2 sampling rate

figure(2)
subplot(2,1,1),plot(f1,abs([So(1:(N1/2))]))
xlabel('Frequency(HZ)');ylabel('Gain');
title('(original):1041110990');
subplot(2,1,2)
plot(f2,abs([Sn(1:(N2/2))]))
xlabel('Frequency(HZ)');ylabel('Gain');
title('(noisy):1041110990');

% The Parameters in Filter Specifications
fp00; % passband edge frequency
fs 00; % stopband edge frequency
df = (fs-fp)/FS;
N = 3.1/df; %the order of the filter
fc=0.5*(fs+fp) % the cut-off frequency
wnFS*2 % normailzed cut-off frequency

%The Required Minimum Attenuation is 30dB so we can use Hanning or Hamming
%or Blackman window

%Using Hanning window
h=fir1(62,wn,hann(63)); %designing the FIR filter
figure(3); stem(h);
fvtool(h) % The magnitude response
figure(6)
freqz(h); % The frequency response
Yf=filter(h,1,Yn) %Obtining the filtered Signal

% playing the filtered sound
%soundsc(Yf)
wavwrite(Yf,'1041110990f.wav');

%Ploting Orginal,Noisy and Filter signals'Frequency spectra
Sft(Yf); %use FFT to transform Filtered signal into frequency domain
f3=(0:((N1/2)-1))/(N1/2)*(FS/2); %define freq. up to 1/2 sampling rate

figure(7)
subplot(3,1,1),plot(f1,abs([So(1:(N1/2))]))
xlabel('Frequency(HZ)');ylabel('Gain');
title('(original):1041110990');
subplot(3,1,2)
plot(f2,abs([Sn(1:(N2/2))]))
xlabel('Frequency(HZ)');ylabel('Gain');
title('(noisy):1041110990');
subplot(3,1,3)
plot(f3,abs([Sf(1:(N2/2))]))
xlabel('Frequency(HZ)');ylabel('Gain');
title('(Filtered):1041110990');
 
THE AUDIO FILES ARE ATTACED
--- On Thu, 5/27/10, Mahera wrote:
From: Mahera
Subject: [matlab] Lowpass filter design
To: m...
Date: Thursday, May 27, 2010, 6:00 AM
 

Dear all,

can anybody give me a simple MATLAB code for designing a lowpass FIR filter and show impulse responses? Please help.
Hello,

Does anyone know how to make a code add drop heuristic algorithm, or you ever been use that algorithm for data analyze.

Please share.

Thank you :)
Bonny-

> Does anyone know how to make a code add drop heuristic algorithm,
> or you ever been use that algorithm for data analyze.
>
> Please share.

What does this have to do with lowpass filter design?

-Jeff