필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
yang-En Hsiao
yang-En Hsiao 2019년 4월 21일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Stephen23
Stephen23 2019년 4월 21일
편집: Stephen23 2019년 4월 21일
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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 4월 21일
Your noise is complex valued, so your received_signal is complex valued. However, your if statements treat it as if it were real valued.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by