Warning: Ignoring extra legend entries

4 visualizzazioni (ultimi 30 giorni)
sarah
sarah il 24 Dic 2012
Hi! I need help.I am trying to display multiple graphs for totalSubcarriers = 64 ,256.I got the graphs, but the result not what i expected.plus I oso got this Warning: Ignoring extra legend entries.i am not sure whats wrong.is it the loops or something else?
function paprOFDMA()
dataType = 'Q-PSK'; % Modulation format.
totalSubcarriers = [64 256 ]; % 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;
numRuns = 1000; % Number of runs.
papr = zeros(1,numRuns); % Initialize the PAPR results.
for h = 1:length (Nsub);
Fsub = [0:Nsub(h)-1]*Fs/Nsub(h); % Subcarrier spacing
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(h)*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)),'-d')
grid on;
legend ('N=64','N=256')
hold all
xlabel('papr, x dB')
ylabel('ccdf')
end
% Save data.
save paprOFDMA

Risposte (1)

Wayne King
Wayne King il 24 Dic 2012
You only have one plot on the figure.
[N,X] = hist(papr, 100);
semilogy(X,1-cumsum(N)/max(cumsum(N)),'-d')
grid on;
but then you try to to put on legend on as if you had two plots on the same graph.
That's why you get the warning.
  2 Commenti
sarah
sarah il 24 Dic 2012
Then how to make this part display multiple plots?
%Plot CCDF.
[N,X] = hist(papr, 100);
semilogy(X,1-cumsum(N)/max(cumsum(N)),'-d')
grid on;
Matt Kindig
Matt Kindig il 24 Dic 2012
Hi sarah,
Provided that you want all of the histograms to overlay each other, just add 'hold on' after the semilogy command, i.e.
semilogy(X,1-cumsum(N)/max(cumsum(N)),'-d')
grid on; hold on;

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by