How to plot two graph using different colour?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2021-5-9
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 个评论
Walter Roberson
2021-5-14
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Test and Measurement 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!