How to plot two graph using different colour?
2 views (last 30 days)
Show older comments
EbNo = 4:2:20;
ber = zeros(length(EbNo),20);
for L = 1:2
ber(:,L) = berfading(EbNo,'qam',8,L);
end
figure(18);
semilogy(EbNo,ber,'b')
text(18.5, 0.02, sprintf('L=%d',1))
text(18.5, 1e-11, sprintf('L=%d',2))
title('ofdm and optical ofdm ber curve')
xlabel('E_b/N_0 (dB)')
ylabel('BER')
legend({'ofdm','optical ofdm'},'Location','southwest')
grid on
But as per the graph both graphs are having same colour,I want that both graphs must be plotted with different colour.How can be done?
0 Comments
Answers (1)
Walter Roberson
on 9 May 2021
semilogy(EbNo,ber,'b')
The 'b' specifically says to use blue for all 20 of the lines. (Only 2 of the lines are obvious because ber = zeros(length(EbNo),20); initialized the 20 lines to all zeros so the other 18 are all in the same place along the axes.)
If you want different colors for each line, then do not use 'b' in the semilogy() call.
4 Comments
Walter Roberson
on 14 May 2021
data_source= abs(round(randn(1,no_of_data_bits)));%here we take random normal function
So data_source will be a 1 x no_data_bits vector of non-negative integers, unlikely to be symmetric.
qam_modulated_data = qammod(data_source, M);%here we perform 8bit qam on the random normal function
You qammod that stream.
y=ifft(qam_modulated_data);
you ifft() the qam modulated data.
nErrors = biterr(y,y1);
and try to calculate the bit error rate using the ifft() values.
However, qam_modulated_data is quite unlikely to just happen to be a skew-symmetric complex-conjugate array, so the ifft of it is almost certain to be complex valued, and so not bit values.
qammod() takes a sequence of M consecutive bits and map them into a single complex value, with the value being deterministic according to the input bits. 01001101 on input will always produce the same complex number on output. Time-domain data remains time domain data, just encoded into a complex number. qammod() does not produce frequency domain data, so you should never expect that ifft() of qammod() will happen to produce real-valued time-domain data.
See Also
Categories
Find more on Test and Measurement in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!