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.

[SOLVED] PAPR in OFDM using MATLAB;help me with this code

Status
Not open for further replies.

Marina90

Newbie level 4
Newbie level 4
Joined
Dec 5, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,324
Hi, i am Marina currently working on PAPR in OFDM using matlab.How do i modify the code below so that i can display PAPR for N=64,256,512,1024 on the same graph?N is the total subcarriers..:|

************************************************************
function paprOFDMA()

dataType = 'Q-PSK'; % Modulation format.
totalSubcarriers = 64; % Number of total subcarriers.
numSymbols = 16; % Data block size.
Fs = 5e6; % System bandwidth.
Ts = 1/Fs; % System sampling rate.
Nos = 4; % Oversampling factor.
Nsub = totalSubcarriers;
Fsub = [0:Nsub-1]*Fs/Nsub; % Subcarrier spacing
numRuns = 1000; % Number of runs.

papr = zeros(1,numRuns); % Initialize the PAPR results.

for n = 1:numRuns,
% Generate random data.
if dataType == 'Q-PSK'
tmp = round(rand(numSymbols,2));
tmp = tmp*2 - 1;
data = (tmp:),1) + j*tmp:),2))/sqrt(2);
elseif dataType == '16QAM'
dataSet = [-3+3i -1+3i 1+3i 3+3i ...
-3+i -1+i 1+i 3+i ...
-3-i -1-i 1-i 3-i ...
-3-3i -1-3i 1-3i 3-3i];
dataSet = dataSet / sqrt(mean(abs(dataSet).^2));
tmp = ceil(rand(numSymbols,1)*16);
for k = 1:numSymbols,
if tmp(k) == 0
tmp(k) = 1;
end
data(k) = dataSet(tmp(k));
end
data = data.';
end

% Time range of the OFDM symbol.
t = [0:Ts/Nos:Nsub*Ts];

% OFDM modulation.
y = 0;
for k = 1:numSymbols,
y= y + data(k)*exp(j*2*pi*Fsub(k)*t);

end

% Calculate PAPR.
papr(n) = 10*log10(max(abs(y).^2) / mean(abs(y).^2));
end

%Plot CCDF.
[N,X] = hist(papr, 100);
semilogy(X,1-cumsum(N)/max(cumsum(N)),'b')
xlabel('papr, x dB')
ylabel('ccdf')

% Save data.
save paprOFDMA
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top