% Make gaussian peaks
% x is time point vector
% a is scaling factor
% m is peak max time point
% s is stdev (peak width)
% y is function (detector) response
% d are curve parameters [a m s] with 1st estimates within brackets

x=[0:0.1:20]';
a1=10;
m1=8;
s1=0.65;
a2=7;
m2=10;
s2=0.65;
y1=gaussian(x,a1,m1,s1);
y2=gaussian(x,a2,m2,s2);
y3=y1+y2;

#plot(x,y1,x,y2,x,y3);
#plot(x,y1,x,y);
#plot(x,y1);

X=[x y3];
d=fminsearch(@(d) fitexp2(d,X),[9 7 0.6 6 9 0.6]);
a1m=d(1);
m1m=d(2);
s1m=d(3);
a2m=d(4);
m2m=d(5);
s2m=d(6);

y1mod=gaussian(x,a1m,m1m,s1m);
y2mod=gaussian(x,a2m,m2m,s2m);
y3mod=y1mod+y2mod;
plot(x,y3,'o',x,y1mod,x,y2mod,x,y3mod);
