problem when copying a plot line to another

I am new to Matlab.
Can anyone help me with the problem when I copy the graph line of the BPSK to the plot of the BFSK, the pasted BPSK has wrong x-axis values. The red lline must cross the x-axis at 9.6.
thanks in advance for any help!

6 个评论

This is how must BPSK look like.
Osamam - could you show us the code that you are using to copy the plot from one figure to the other?
This is the code gor the copied plot
close all; clc;
num_bits = 300000; % signal lenghth
max_run = 10; % maximum number of iterations for a single SNR
Eb = 1; % bit energy
k=1; n=1;
R=k/n; % the rate
SNR_db = 0:0.5:13; % signal to noise ratio in db
SNR = 10.^(SNR_db/10);
hand = waitbar(0,'Simulation is being processed,please wait...');
for count = 1:length(SNR) % begining of loop for different SNR, all SNR
avgError = 0;
sigma=sqrt((Eb/(2*R*SNR(count))));
for run_time=1:max_run % begining of loop for different runs
waitbar((count*max_run)/(length(SNR_db)*max_run));
Error = 0;
data = randi([0 1],1,num_bits); % generate binary data source
S = 2*data-1; % baseband BPSK modulations
N = sigma*randn(1,num_bits); % generate AWGN
Y = S+N; % Received noist signal
for k = 1:num_bits % Decision device taking hard decision and deciding error
if ((Y(k)>0 && data(k)==0)||( Y(k)<0 && data(k)==1))
Error=Error+1;
end
end
Error=Error/num_bits; % caulculate error/bit
avgError=avgError+Error; % caulculate error/bit for different runs
end % Termination of loop for differwnt runs
BER_sim(count)=avgError./max_run; % calculate BER for a particular SNR
end % Termination of loop for differnet SNR
BER_th=(1/2)*erfc(sqrt(SNR)); % calculate the analytical BER
close(hand);
semilogy(SNR_db,BER_th,'r');% you can change the graph style r-* or r-o or r-x
grid on
hold on
%semilogy(SNR_db,BER_th_coded,'g');
hold on
semilogy(SNR_db,BER_sim,'b*');
title('PBSK under AWGN simulation and theoritcal');
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')
legend('Theortical','Simulation','location','SouthWest');
axis ([min(SNR_db) 10 10^(-5) 10^(-1)]);
hold off
You are using a log y plot. It cannot cross the x axes, because crossing the x axes would be y=0 which would be infinitely far down because of the log scale.
I think he meant literally 'crossing' as in 'visually touching' the x-axis at 9.6, not to cross y=0
In my opinion, this is an issue on setting the minimum value for the y-axis (ymin). The values plotted in red line and blue stars look the same for me.
Thanks so much! I got it.
becasue the y axsis is not the same for both graphs, the problem occured.

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by