simulate LDPC simulink & LDPC Matlab using same script
1 view (last 30 days)
Show older comments
hello, I want to simulate a Simulink model from a Matlab script. so I use the script below but I do not get the good results.
the inputs
Lci changes each frame and I get the outputs at each frame too. is there another method that is used
global Lc1;
global Lc2;
global Lc3;
global Lc4;
global Lc5;
global Lc6;
global Lc7;
global Lc8;
global Lc9;
global Lc10;
R=1/2;
Mo=2;
numerrmin =1000;
SNRdB=1:1:6;
BER_bit=zeros(size(SNRdB));
BER_bit2=zeros(size(SNRdB));%MSA
codewordH=[0,0,0,0,0,0,0,0,0,0];
modulatedsig=1-2*codewordH;
format long;
for k=1:length(SNRdB)
fprintf('SNR:%d\n',SNRdB(k))
frame=0;
numerr=0;
numerr2=0;
rat_err=0;
rat_err2=0;
EbN0_lin=10^(SNRdB(k)/10);
EsN0_lin=EbN0_lin*R*log2(Mo);
Es= 1 ;
N0=Es/EsN0_lin;
sigma=sqrt(N0/2);
while(numerr2 < numerrmin)
frame = frame + 1;
fprintf('frame : %d\n',frame)
bruit= randn(size(modulatedsig));
receivedsig =modulatedsig+sigma.*bruit;
Lci = (4.*(receivedsig./N0));
Lc1=Lci(1);
Lc2= Lci(2);
Lc3=Lci(3);
Lc4=Lci(4);
Lc5=Lci(5);
Lc6=Lci(6);
Lc7=Lci(7);
Lc8=Lci(8);
Lc9=Lci(9);
Lc10=Lci(10);
Lc1=timeseries(Lc1);
Lc2=timeseries(Lc2);
Lc3=timeseries(Lc3);
Lc4=timeseries(Lc4);
Lc5=timeseries(Lc5);
Lc6=timeseries(Lc6);
Lc7=timeseries(Lc7);
Lc8=timeseries(Lc8);
Lc9=timeseries(Lc9);
Lc10=timeseries(Lc10);
s=sim('LDPCMatlabSimulink');
%pause(5);
%sim('LDPCMatlabSimulink',');
x1=getdatasamples(x1,1);
x2=getdatasamples(x2,1);
x3=getdatasamples(x3,1);
x4=getdatasamples(x4,1);
x5=getdatasamples(x5,1);
x6=getdatasamples(x6,1);
x7=getdatasamples(x7,1);
x8=getdatasamples(x8,1);
x9=getdatasamples(x9,1);
x10=getdatasamples(x10,1);
SMS=[x1 x2 x3 x4 x5 x6 x7 x8 x9 x10];%%%%%[0 0 0 0 0 0 0 0 0 0];%%
% %iteration=it;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [decodedmsg2,n]= minsum_sfixed(receivedsig,N0, H,num_iter);
% [Num2,Rat2] = biterr(codewordH,decodedmsg2);
% numerr2=numerr2+Num2;
% rat_err2=rat_err2+Rat2;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Num1,Rat1] = biterr(codewordH,SMS);
numerr=numerr+Num1;
rat_err=rat_err+Rat1;
if frame>5
break;
end
end
BER_bit(k)=rat_err/frame;
BER_bit2(k)=rat_err2/frame;
end
figure(1)
semilogy(SNRdB, BER_bit,'ro-','LineWidth',2);
hold on;
semilogy(SNRdB, BER_bit2,'*-g','LineWidth',2);
grid on;
xlabel('SNR,(dB)')
ylabel('Bit-Error-Rate(BER)')
legend('MSA-Simulink','matlab')
gives these results!!!!!
the good results(the green )
i don't know wher's the problème??
0 Comments
Answers (0)
See Also
Categories
Find more on Software Development Tools in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!