clear
pack
hold off;
t100=clock;

eta=.667;h=6.625*10^(-34);c=3*10^8;l=1.173*10^(-6);
ni=c/l;p=1.0*10^(-8.1);
g=80;kef=.04;t1=(22/9)*10^(-9);
q=1.6*10^(-19);
fe=kef*g+(2-1/g)*(1-kef);
ne=p*eta*t1/(h*ni);
sigma=(g*q*sqrt(ne*fe))/t1;m=(ne*g*q)/t1;
lambda=(sqrt(ne*fe))/(fe-1);
a1=[4.5 21 50 80 82 60 30 9 1.18];
a=10^9*(1/337.68).*a1;
m1=m.*a;
sigma1=sigma.*a;
%m1(1)=m;
%sigma1(1)=sigma;
x=(1:.5:1000);
mi=m*10^9
sigmai=sigma*10^9
ui=1+(x-mi)./(lambda*sigmai);

u1=1+(x-m1(1))./(lambda*sigma1(1));
u2=1+(x-m1(2))./(lambda*sigma1(2));
u3=1+(x-m1(3))./(lambda*sigma1(3));
u4=1+(x-m1(4))./(lambda*sigma1(4));
u5=1+(x-m1(5))./(lambda*sigma1(5));
u6=1+(x-m1(6))./(lambda*sigma1(6));
u7=1+(x-m1(7))./(lambda*sigma1(7));
u8=1+(x-m1(8))./(lambda*sigma1(8));
u9=1+(x-m1(9))./(lambda*sigma1(9));
wi=(1./(sqrt(2*pi)*sigmai.*ui.^1.5)).*exp(-1.*(x-mi).^2 ./(2*sigmai^2 .*ui));
y=10^5 .*wi;
r=round(y);
sc=cumsum(y);
sc2=0:length(sc)-1;
plot(sc2,sc)
w1=(1./(sqrt(2*pi)*sigma1(1).*u1.^1.5)).*exp(-1.*(x-m1(1)).^2 ./(2*sigma1(1)^2 .*u1));
w2=(1./(sqrt(2*pi)*sigma1(2).*u2.^1.5)).*exp(-1.*(x-m1(2)).^2 ./(2*sigma1(2)^2 .*u2));
w3=(1./(sqrt(2*pi)*sigma1(3).*u3.^1.5)).*exp(-1.*(x-m1(3)).^2 ./(2*sigma1(3)^2 .*u3));
w4=(1./(sqrt(2*pi)*sigma1(4).*u4.^1.5)).*exp(-1.*(x-m1(4)).^2 ./(2*sigma1(4)^2 .*u4));
w5=(1./(sqrt(2*pi)*sigma1(5).*u5.^1.5)).*exp(-1.*(x-m1(5)).^2 ./(2*sigma1(5)^2 .*u5));
w6=(1./(sqrt(2*pi)*sigma1(6).*u6.^1.5)).*exp(-1.*(x-m1(6)).^2 ./(2*sigma1(6)^2 .*u6));
w7=(1./(sqrt(2*pi)*sigma1(7).*u7.^1.5)).*exp(-1.*(x-m1(7)).^2 ./(2*sigma1(7)^2 .*u7));
w8=(1./(sqrt(2*pi)*sigma1(8).*u8.^1.5)).*exp(-1.*(x-m1(8)).^2 ./(2*sigma1(8)^2 .*u8));
w9=(1./(sqrt(2*pi)*sigma1(9).*u9.^1.5)).*exp(-1.*(x-m1(9)).^2 ./(2*sigma1(9)^2 .*u9));

c1=conv(w1,w2);
c2=conv(c1,w3);
c3=conv(c2,w4);
c4=conv(c3,w5);
c5=conv(c4,w6);
c6=conv(c5,w7);
c7=conv(c6,w8);
c8=conv(c7,w9);

d=round(wi.*10000);
s=sum(d)
o=0:length(c1)-1;
o1=0:length(c2)-1;
o2=0:length(c3)-1;
o3=0:length(c4)-1;
o4=0:length(c5)-1;
o5=0:length(c6)-1;
o6=0:length(c7)-1;
o7=0:length(c8)-1;

semilogy(o,c1,'w')
hold on
semilogy(x,w1,'y') 
hold on
semilogy(o1,c2,'c')
hold on
semilogy(o2,c3,'r')
hold on
semilogy(o3,c4,'b')
hold on
semilogy(o4,c5,'g')
hold on
semilogy(o5,c6,'m')
hold on
semilogy(o6,c7,'b')
hold on
semilogy(o7,c8,'r')
hold on
axis([0 3000 10^(-100) 10^0]);grid
durata=etime(clock,t100)

%sum(c8)
sigmath=14.68;
sigmath2=(sigmath)^2;
e2=1/(sqrt(2*pi)*sigmath);
x1=-200:10:200;
g=e2.*exp(-x1.^2 ./(2*sigmath2));
cg=conv(c7,g);
og=0:length(cg)-1;
semilogy(og,cg,'w')

