Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Why is the last simulation value is "0",i can't find where is wrong

1 vue (au cours des 30 derniers jours)
yang-En Hsiao
yang-En Hsiao le 21 Avr 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
I write an error probability of anti-podal,however,i found the last simulation value is zero,it means that there is no any error signal in the receiver at that time,but that is possible,and i can't find where do i wrong,can anyone help me?
Code
T_s=10^4;
SNR_dB=[-3 0 3 6 9];
SNR_Watt=10.^(SNR_dB./10);
anti_signal=rand(1,T_s)
%Create the anti-podal signal
for ii=1:length(SNR_dB)
for t=1:T_s
if anti_signal(t)>0.5
anti_signal(t)=1;
else
anti_signal(t)=-1;
end
end
%AWGN noise
noise=(1/sqrt(2)*[randn(1,T_s)+1i*randn(1,T_s)]);
%receive_signal
%10.^(-SNR_dB(ii)/20)*noise is the noise in "x" SNR,like -3dB,0dB,3dB,6dB and 9dB
receive_signal=anti_signal+10.^(-SNR_dB(ii)/20)*noise;
for q=1:T_s
if receive_signal(q)>0
receive_signal(q)=1;
else
receive_signal(q)=-1;
end
end
simulation(ii)=(T_s-sum(anti_signal==receive_signal))/T_s%(Total number-the number which is right)-Total number
end
theoretical=1/2*erfc(sqrt(SNR_Watt));
semilogy(SNR_dB,simulation,SNR_dB,theoretical)
The simulation result is as below,as we can see,the last number is always "0",why?i think there is something wrong in the code,but if this 0 is correct,i can't find a reasonable reason to convince to me
smu.PNG
  1 commentaire
Stephen23
Stephen23 le 21 Avr 2019
Modifié(e) : Stephen23 le 21 Avr 2019
Note that you should preallocate that array before the loop:
....
N = numel(SNR_db);
simulation = nan(1,N); % !!! Preallocate !!!
for ii = 1:N
....
simulation(ii) = ...
end

Réponses (1)

Walter Roberson
Walter Roberson le 21 Avr 2019
Your noise is complex valued, so your received_signal is complex valued. However, your if statements treat it as if it were real valued.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by