function [p]=kompilace
disp('Vypocet maximalni delky vlakna pri zadani prenosove rychlosti (pouze s vlivem PMD)')
r=input('Zadej velikost polarizacni vidove disperze v [ps/sqrt(km)]    ');
a=input('zadej prenosouvou rychlost v [Gb/s]:  ');
PMD=r*1e-12;
b=a*1e9;
d=b/160;
c=b/17;
dT=0.15*(1/b);
disp('Maximalni delka vlakna [km]')
Lmax=(dT/PMD)^2
disp('Maximalni delka vlakna s pouzitim technologie CWDM [km]')
dTc=0.15*(1/c);
Lmax=(dTc/PMD)^2
disp('Maximalni delka vlakna s pouzitim technoligie DWDM [km]')
dTd=0.15*(1/d);
Lmax=(dTd/PMD)^2
disp('Zobrazeni zavislosti delky vlakna na PMD zadane rychlosti')
disp('pokracujte libovolnou klavesou')
pause()
format short

c=load('hodnoty.txt');
m=0;
for z=1:length(c);
   m=m+1; 
L(m,:)=(dT/c(m,:))^2;
L40(m,:)=(3.75e-12/c(m,:))^2;
L10(m,:)=(1.5e-11/c(m,:))^2;
end

figure(1)
grid on
semilogy(c,L,'b*-')
title ('Zavislost delky vlakna na PMD zadane prenosove rychlosti')
xlabel('PMD [ps]')
ylabel('delka vlakna [km]')
figure(2)
subplot(2,1,1)
semilogy(c,L,'b*-')
title ('Zavislost delky vlakna na PMD zadane prenosove rychlosti')
xlabel('PMD [ps]')
ylabel('delka vlakna [km]')
subplot(2,1,2)
semilogy(c,L40,'r*-',c,L10,'g*:')
title ('Zavislost delky vlakna na PMD ')
xlabel('PMD [ps]')
ylabel('delka vlakna [km]')
legend('40Gb/s','10Gb/s')
disp('pokracujte libovolnou klavesou')
pause()


disp('Vypocet maximalni prenosove rychlosti na zadane trase (pouze s vlivem PMD)')
pause(1)
x=input('Zadej delku vlakna [km]:  ');
format long
dT=PMD*sqrt(x);
disp('Maximalni prenosova rychlost po jednom kanale [Gb/s]')
B=(0.15/dT)*1e-9
disp('Maximalni prenosova rychlost s pouzitim technologie CWDM [Gb/s]')
CWDM=(B*17)
disp('Maximalni prenosova rychlost s pouzitim technologie DWDM [Gb/s]')
DWDM=(B*150)

%Maxwellova krivka
disp('Zobrazeni maxwellovy krivky v zavislosti na zadane vzdalenosti')
format short
disp('pokracujte libovolnou klavesou')
pause()
PMD=1;
ODL=sqrt(x);
dtavg=PMD*ODL;
sigma=(sqrt(2*pi)*dtavg)/4;
if x<=10;
     a=load('DGDhodnoty10.txt');
    else
    a=load('DGDhodnoty.txt');
  if (x>10)&(x<=30);
     a=load('DGDhodnoty30.txt');
   else
    a=load('DGDhodnoty.txt');
  if (x>30)&(x<=100);
    a=load('DGDhodnoty100.txt');
   else
    a=load('DGDhodnoty.txt');
 if (x>100)&(x<=150)
      a=load('DGDhodnoty150.txt');
  else
      a=load('DGDhodnoty.txt');
       
       
  end;
  end;    
  end;
end;
u=0;
for t=1:length(a);
    u=u+1;
ro(u,:)=sqrt(2/pi)*(a(u,:)^2/sigma^3)*exp(-((a(u,:)^2)/(2*(sigma^2))));
end
PMD1=2;
ODL1=sqrt(x);
dtavg1=PMD1*ODL1;
sigma1=(sqrt(2*pi)*dtavg1)/4;
u=0;
for t=1:length(a);
    u=u+1;
ro1(u,:)=sqrt(2/pi)*(a(u,:)^2/sigma1^3)*exp(-((a(u,:)^2)/(2*(sigma1^2))));
end
PMD2=3;
ODL2=sqrt(x);
dtavg2=PMD2*ODL2;
sigma2=(sqrt(2*pi)*dtavg2)/4;
u=0;
for t=1:length(a);
    u=u+1;
ro2(u,:)=sqrt(2/pi)*(a(u,:)^2/sigma2^3)*exp(-((a(u,:)^2)/(2*(sigma2^2))));
end
PMD3=4;
ODL3=sqrt(x);
dtavg3=PMD3*ODL3;
sigma3=(sqrt(2*pi)*dtavg3)/4;
u=0;
for t=1:length(a);
    u=u+1;
ro3(u,:)=sqrt(2/pi)*(a(u,:)^2/sigma3^3)*exp(-((a(u,:)^2)/(2*(sigma3^2))));
end
figure(3)
plot(a,ro,'y-',a,ro1,'r:',a,ro2,'k-.',a,ro3,'b--')
legend('1 ps*sqrt(km)','2 ps*sqrt(km)','3 ps*sqrt(km)','4 ps*sqrt(km)' )
xlabel('DGD [ps]')
ylabel('hustota pravdepodobnodti')
title('Maxwellova krivka')
disp('pokracujte libovolnou klavesou')
pause(10)
clear all


