Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Magnitude response of Lowpass FIR filter (Matlab2009a)

Status
Not open for further replies.

Naveed Ahmed

Member level 4
Joined
Aug 31, 2008
Messages
77
Helped
9
Reputation
18
Reaction score
9
Trophy points
1,288
Location
Singapore
Activity points
1,862
Hi,

I have written a test program in matlab for lowpass fir, when i m plotting its magnitude response after fft, it seems to be a high pass filter. Why its doing so??
My code is as follow:

N=50; %Filter order
Length=N+1; %length
n0=N/2; %delay parameter
n=0:1:N;
fc_l=1/8; %Cut off frequency for the low pass filter
Wc_l=2*pi*fc_l;
%===================LOWPASS FIR FILTER=====
h_lp=sin(Wc_l*(n-n0)) ./(pi*(n-n0)); %Impulse response of Low Pass FIR filter For n-n0!=0
h_lp(n0+1)=(Wc_l/pi) %Imp response of Low Pass FIR filter For n=n0 or n-n=0
F=fft(h_lp,51);
X=real(F);
Y=imag(F);
[th,Mag]=cart2pol(X,Y);
plot(0:50,Mag)

Thanks,

Your comments plz

naveed
 

i think what you have there is band-stop.. i might be wrong..

anyway.. here is my FIR...
hope it works for you:
Code:
%my finite imp resp filter
clear all; clc; close all;

[b,a] = fir1(50, 1/8,'low'); % creating your filter
    %fir1(order usually 30-50, cuttoff_normalized_freq, 'type high, low, band')
    
%this is to view your filter
figure(1);
freqz(b,a);

N=500; %number of points to calculate
fe=5000; 
n=0:1:N-1;
%your input signal
x=sin(2*pi*200*n/fe)+sin(2*pi*1400*n/fe);
%one passes, one doesn't;

%now filtering the signal y with this FIR
figure(2);
y=filter(b,1,x);
subplot(2,1,1);
plot(n,x);grid;legend('input signal'); xlabel('time'); ylabel('ampl');
subplot(2,1,2);
plot(n,y); grid; legend('output filtered signal'); xlabel('time'); ylabel('ampl');
:p
 

hey koolariz
handy code you provided there, thanks

i have a question though, i need to calculate a low pass filter of F(k) (being a vector), which has values from 0 to 1.
im supposed to calculate it with a fir lowpass filter using 50 taps, the value of each coefficient being 1/50.
this is all my information. do i miss something?

and im not quite sure how to do it.
thanks in advance
nik.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top