MATLAB: Peak additions /array addition

arrayMATLAB

I have some code calculating each individual peaks, how can i store them into a large array according to X axis and add them up if they are overlapped.so i should get something like the plot ,
For small range of vt, it will work when I use vt = 5323:stp:5330;
but it wont work if the range is big, say vt=5000:6000. Thanks,
My code:
DT = [1 1 5323.951020 9.682E-22 1.867E+00 .09040 .454
1 1 5327.295500 4.680E-23 2.287E+00 .07510 .301
1 1 5327.390350 1.819E-20 9.299E+00 .10290 .443
1 1 5327.648670 5.002E-23 7.875E-02 .09590 .439
1 1 5327.678120 8.068E-23 5.441E-02 .09320 .429
1 2 5327.964260 1.694E-23 3.105E+00 .09720 .474
1 1 5328.113150 5.769E-23 5.578E-02 .08630 .420
1 1 5329.995810 4.922E-22 1.668E-01 .07400 .460
1 1 5330.470210 3.135E-23 3.254E-02 .09880 .510]; % test data
T = 266;
P = 0.95;
stp = P/100;
a = 1/2.5;
Vgt = 0;
gD(k) = 1.23E-4*sqrt(T/22);
gL(k) = 0.1*P;
for k =1:1:length(DT(:,1))
% % %%% calcualte each peak with 401 pts
vt = DT(k,3)-200*stp:stp:DT(k,3)+ 200*stp;
x=3*(vt-DT(k,3))/gD(k);
y =3*gL(k)/gD(k);
sigma1=0;
sigma2=0;
sigma3=0;
for n = 1:1:20000
sigma1 = sigma1 + 1/(a^2*n^2 + y^2).* exp(-(a^2*n^2 + x.^2));
sigma2 = sigma2 + 1/(a^2*n^2 + y^2).* exp(-(a*n + x).^2);
sigma3 = sigma3 + 1/(a^2*n^2 + y^2).* exp(-(a*n - x).^2);
end
Vgt = exp(-x.^2).*erfcx(y).*cos(2*x.*y)+...
2*a*x.*sin(x.*y)/pi.*exp(-x.^2).*sin(x*y)/(x*y)+...
2*a/pi.*(-y.*cos(2*x.*y).*sigma1 + y/2.*sigma2 +y/2.*sigma3);
hold on;
plot(vt,Vgt,'.-b')
end

Best Answer

We don't understand what you're asking. To add arrays, just use the "+" operation:
sumArray = array1 + array2 + array3;