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.

code for fir filter design in matlab

Status
Not open for further replies.

shubhs9

Newbie level 4
Joined
Jan 29, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,336
hi.

I have written a code which emulates a qpsk tx n rx system. it works perfectly and i'm getting the BER curve exactly.

As my next task i have been asked to design an fir low pass filter through which i am to pass the qpsk signal. i'm not getting much assistance from the guide and i'm pretty much on my own. I would really appreciate it if someone could help me out.

thanks.

-shubro


the code for qpsk:

nr_data_bits=100000; %number of bits to be generated
b_data = (randint(1, nr_data_bits)); %random 1's and 0's
b = (b_data);
s = length(b); %length of sequence

d=zeros(1,length(b)/2); %initializing a variable with all zeros
for n=1:length(b)/2
imp=b(2*n-1); %selecting one bit
p=b(2*n); %selecting consequent bit
if (imp==0)&&(p==0)
d(n)=exp(j*pi/4); %45 degrees
end
if (imp==1)&&(p==0)
d(n)=exp(j*3*pi/4); %135 degrees
end
if (imp==1)&&(p==1)
d(n)=exp(j*5*pi/4); %225 degrees
end
if (imp==0)&&(p==1)
d(n)=exp(j*7*pi/4); %315 degrees
end
end
qpsk=d;

figure(1);
plot(d,'o'); %plot constellation without noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');
hold on;

SNR=0:10;
de1=[];
de=[];
BER1=[];
SNR1=[];
for SNR=0:length(SNR);
de1 = [];
sigma = sqrt(10.0^(-SNR/10.0)); %No/Eb = sqrt(antilog(snr/10))
sigma = sigma/2; %noise spectral density = No/2
corrupt = sigma.*(randn(1,length(b)/2)+j*randn(1,length(b)/2));
r = qpsk + corrupt;
for n=1:length(b)/2
g=r(n);
imp=b(2*n-1);
p=b(2*n);
if (real(g) > 0)
if (imag(g) > 0)
de = [0 0];
end
end
if (real(g) < 0)
if (imag(g) > 0)
de = [1 0];
end
end
if (real(g) > 0)
if (imag(g) < 0)
de = [0 1];
end
end

if (real(g) < 0)
if (imag(g) < 0)
de = [1 1];
end
end
de1=[de1 de];
end
ne=sum(b~=de1)
BER=ne/nr_data_bits;
BER1=[BER1 BER]
SNR1=[SNR1 SNR]
end

figure(1);
plot(r,'x'); %plot constellation with noise
axis([-2 2 -2 2]);
grid on;
xlabel('real'); ylabel('imag');

figure(2);
semilogy(SNR1,BER1,'o');
grid on;
xlabel('SNR'); ylabel('BER');
 

I've replied on the telecom_research yahoo group too and will do the same here that why do you want to pass it through the FIR filter?

Is it a pulse shaping filter?
 

i'm being asked to pass through the filter so that i can notice the difference.

the entire task is to pass the qpsk signal through the filter and then add noise to it.
 

what kind of fir filter? what is its impulse response.

you can design an fir filter in matlab using function fir1 (type doc fir1 in the command window to learn about it)

and use filter(qpsk,filtercoeffs) to take the output
 

oh ok.. like that.. and how should i put the coefficients as?

Added after 3 minutes:

meaning should i put it as a sequence of numbers?
 

hello..I have a problem. I want to know how to design a pulse shaping FIR filter in Matlab when the input to this filter is Gaussian pulse. Could you help me please? In my case the output of this pulse shaping filter should be 5th order derivative Gaussian pulse.

Thanks. waiting for the reply.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top