Re: [問題] 可以幫我看看BPSK嗎?已回收

看板MATLAB作者 (ck901004)時間14年前 (2009/10/16 01:09), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
您好,我稍微看了一下。 不太愛用 function,改成整份code, SNR_dB1=0:2:10; SNR_dB2=0:0.1:10; bit_err_prb=zeros(1,length(SNR_dB1)); theo_err_prb=zeros(1,length(SNR_dB2)); for i=1:length(SNR_dB1), N=5000; E=1; % energy per symbol snr=10^(SNR_dB1(i)/10); vari=sqrt(E/snr/2); % 修正一 % generate of the random data sourses between 0 & 1 data_s=sign(randint(1,N)-0.5); % dection and the probability of error calculation numofbiterror=0; for j=1:N, n=vari*randn;     % 修正二 r=data_s(j)+n; % correlation metrics c00=dot(r,1); % 1 c01=dot(r,-1); % 0 c_max=max([c00,c01]); if (c00==c_max), decis=1; elseif (c01==c_max), decis=-1; end % increment the error counter, if the decision is not correct if(decis~=data_s(j)), numofbiterror=numofbiterror+1; end end pb=numofbiterror/N; bit_err_prb(i)=pb; end for i=1:length(SNR_dB2), SNR=exp(SNR_dB2(i)*log(10)/10); theo_err_prb(i)=qfunc(sqrt(2*SNR)); end semilogy(SNR_dB2,theo_err_prb,SNR_dB1,bit_err_prb,'r*'); 其實問題出在你的 noise ,其他並無重大錯誤。 希望有幫助~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.137.190.175

10/16 14:34, , 1F
非常謝謝你的幫忙!
10/16 14:34, 1F
文章代碼(AID): #1ArrTNpe (MATLAB)
文章代碼(AID): #1ArrTNpe (MATLAB)