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.

Problem from book: Simulation and Software Radio in Matlab.

Status
Not open for further replies.

allysonsim

Junior Member level 2
Joined
Dec 29, 2007
Messages
24
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,476
paradata=reshape(seldata,para,nd*ml);

Help!

I need someone's help to guide me on Simulating my BER result on Matlab. This is the codes that I have for the moment. Which i modified a lil bit from the code provided by the book.

clc;
clear all;
close all;

para=128; % Number of parallel channel to transmit (points)
fftlen=128; % FFT length
noc=128; % Number of carrier
nd=6; % Number of information OFDM symbol for one loop
ml=8; % Modulation level : QPSK
sr=250000; % Symbol rate
br=sr.*ml; % Bit rate per carrier
gilen=32; % Length of guard interval (points)
ebno=[0:30]; % Eb/N0

%************************** main loop part **************************

nloop=500; % Number of simulation loops

noe = 0; % Number of error data
nod = 0; % Number of transmitted data
eop=0; % Number of error packet
nop=0; % Number of transmitted packet

for i = 1:length(ebno)
for iii=1:nloop

ebn0=ebno(i);
%************************** transmitter *********************************

%************************** Data generation ****************************

seldata=rand(1,para*nd*ml)>0.5; % rand : built in function

%****************** Serial to parallel conversion ***********************

paradata=reshape(seldata,para,nd*ml); % reshape : built in function

%************************** QPSK modulation *****************************

[ich,qch]=qpskmod(paradata,para,nd,ml);
kmod=1/sqrt(2); % sqrt : built in function
ich1=ich.*kmod;
qch1=qch.*kmod;

%******************* IFFT ************************

x=ich1+qch1.*i;
y=ifft(x); % ifft : built in function
ich2=real(y); % real : built in function
qch2=imag(y); % imag : built in function

%********* Gurad interval insertion **********

[ich3,qch3]= giins(ich2,qch2,fftlen,gilen,nd);
fftlen2=fftlen+gilen;

%********* Attenuation Calculation *********

spow=sum(ich3.^2+qch3.^2)/nd./para; % sum : built in function
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);

%*************************** Receiver *****************************
%***************** AWGN addition *********

[ich4,qch4]=comb(ich3,qch3,attn);

%****************** Guard interval removal *********

[ich5,qch5]= girem(ich4,qch4,fftlen2,gilen,nd);

%****************** FFT ******************

rx=ich5+qch5.*i;
ry=fft(rx); % fft : built in function
ich6=real(ry); % real : built in function
qch6=imag(ry); % imag : built in function

%***************** demoduration *******************

ich7=ich6./kmod;
qch7=qch6./kmod;
[demodata]=qpskdemod(ich7,qch7,para,nd,ml);

%************** Parallel to serial conversion *****************

demodata1=reshape(demodata,1,para*nd*ml);

%************************** Bit Error Rate (BER) ****************************

% instantaneous number of error and data

noe2=sum(abs(demodata1-seldata)); % sum : built in function
nod2=length(seldata); % length : built in function

% cumulative the number of error and data in noe and nod

noe=noe+noe2;
nod=nod+nod2;

end
% theoretical Values for BER

ber=noe2/nod2;
BerAwgn = [0.5*erfc(sqrt(ebn0)) 0.5*(1-(1/(sqrt(1+1/ebn0)))) noe/nod]
for k=1:length(BerAwgn)
Berawgn = BerAwgn(k);
% theoretical value for fading

%********************** Output result ***************************

% per=eop/nop;


fprintf('%f\t%e\t%d\t%d\t\n',ebn0,ber,BerAwgn,noe);
markerchoice = '.xo*';
plotsym = [markerchoice(k),'b-']; % Plotting style for this curve
semilogy(ebn0, Berawgn, plotsym); % Plot one curve.
drawnow; % Update the plot instead of waiting until the end.
hold on; % Make sure next iteration does not remove this curve.
end
end
 

paradata matlab

Is there a problem? I'd start by running this in matlab and debugging the output. Starting with a working matlab script and making small changes has worked for me.

Dave
www.keystoneradio.com
 

Re: Problem from book: Simulation and Software Radio in Matl

The code has no problem but the simulated theoretical value of my BER for awgn channel is not correct. I couldn't seems to get the right graph at the end of the simulation.
 

Re: Problem from book: Simulation and Software Radio in Matl

sir
if u have worked in any other code in ofdm mail me at
dixit.dhruva@indiatimes.com
its urgent
thanks n regards
dhruva
 

Re: Problem from book: Simulation and Software Radio in Matl

So does the original code from the book give the right answers? If it does, then when you changed it, you caused the error.


Dave
www.keystoneradio.com
 

Re: Problem from book: Simulation and Software Radio in Matl

I have the softcopy for the codes from the CD. According to the publisher, I can't access to some files whereby the graph for BER is drawn.
When I generate the original codes.. it only give me the value for the BER but not the graph. I have problem plotting the right graph.

another question is that, do I need to change the BER value into dB? Or leave it as it is?
 

I cant get a semilogy plot when I use hold on command with it, the log scale changes to linear scale. This consequence is also written in Matlab help. But how to actually get it, any trick?
 

for the semilogy problem please follow this procedure

semilogy(x1,y1,x2,y2,...)

I also had similar problem some time ago. Hopefully this solves our problem
 

Re: Problem from book: Simulation and Software Radio in Matl

first thank you for your effort, second when i entered this code in matlab , it gives me error which it is Undefined command/function 'qpskmod'.
this means that function is not defined in this version (7.0.4).
what can i do?
 

Re: Problem from book: Simulation and Software Radio in Matl

mohammad hamdy said:
first thank you for your effort, second when i entered this code in matlab , it gives me error which it is Undefined command/function 'qpskmod'.
this means that function is not defined in this version (7.0.4).
what can i do?
it means you don't have function named 'qpskmod' in your current directory...
you need to write a function for qpsk modulation and save in your current directory with filename 'qpskmod.m'
i think it is written in chapter 3 on the book...

what is kmod in the program? It is said something about normalization... anyone can tell me what kmod is?

thx
sorry for my bad english...:D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top