i have this graph that show BER after demodulation.
but in want to show BER after Equalizer too. So i can analysis BER from that graph. so i add this code " semilogy(EbNo,ber,'-or');".
but get error: Error in Vector must be the same length. what's wrong with my code? thank you in advance
this is my code :
%%MMSE
clear
disp('MMSE');
M = 8;
data = rand(1,501,1)'; %Generate random data symbols.
data(data<0.5)=0; data(data>=0.5)=1;
ber = 1; %Initializing
EbNo = 5;
i=1;
while ber(end) >= 1e-3
i=i+1;
EbNo(i) = EbNo(i-1) + 1;
ber(i-1) = berfading(EbNo(end),'psk',M,2);
end
y = awgn(data,EbNo(end)); y(y<mean(y))=0; y(y>=mean(y))=1;
PSK_mod = pskmod(y,M,pi/M);
PSK_demod = pskdemod(PSK_mod,M);
phasemod=PhaseMod(y);
phasedemod=PhaseDemod(phasemod);
eqlms = lineareq(8,lms(0.003)); %ekualizer
EQ = equalize(eqlms,PSK_demod,data); EQ(EQ>=0.5)=1; EQ(EQ<0.5)=0;
[m,n] = biterr(data,PSK_demod);
fprintf('BER after demodulation: %f.\n',n);
[m,n] = biterr(data,EQ);
fprintf('BER after equalizer: %f.\n',n);
fprintf('Thus BER decreases after Equalizer \n');
berMMSE = ber; EbNoMMSE = EbNo(1:length(ber));
figure();
semilogy(EbNoMMSE,berMMSE,'-or'); grid on; grid minor;
% axis([0 14 10^-5 0.5])
semilogy(EbNo,ber,'-or'); grid on; grid minor;
grid on
legend('sim-mmse');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for 8PSK with MMSE equalizer');

回答 (1 件)

dpb
dpb 2016 年 12 月 6 日

0 投票

Well, the two vectors must not be the same length...to plot them against each other, they must be commensurate in size. Let's see what we can see...
...
i=i+1;
EbNo(i) = EbNo(i-1) + 1;
ber(i-1) = berfading(EbNo(end),'psk',M,2);
Aha! You save i values for EbNo, but ber is always one behind...where's the corresponding i value for it? Or, truncate the last EbNo entry or whatever is the correct way to line them up so there are same number of each...

2 件のコメント

raizal muttaqin
raizal muttaqin 2016 年 12 月 7 日
thank you sir. i have change my code with:
...
i=i+1;
EbNo(i) = EbNo(i-1) + 1;
ber(i-1) = berfading(EbNo(end),'psk',M,2);
my output is given
MMSE
BER after demodulation: 0.755489.
BER after equalizer: 0.157685.
But in my output graph still got error. i add this code:
semilogy(EbNo,ber,'-or');
so i can show graph after and before equalizer. the code is not error. but the output still doesn't give expectation output. this is my output in graph
my expectation output is like this graph :
:
dpb
dpb 2016 年 12 月 7 日
Well, your x,y data aren't in synch...note your first Eb/No value is 1 whereas your reference plot begins at 0 and clearly the first value of BER is apparently an end effect or initialization artifact, not the actual computed value.
Your code isn't correct yet; just because it runs doesn't mean it doesn't have logic error. I don't know the field enough to be able to fix the logic without more time expended than I have to give; use the debugger and step through and likely you'll be able to spot what isn't as it should be...

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangePHY Components についてさらに検索

質問済み:

2016 年 12 月 6 日

コメント済み:

dpb
2016 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by