function [aa,ab,ac,ad,ae] =gcarea(pas,paf,pbs,pbf,pcs,pcf,pds,pdf,pes,pef,signaltest)


signal = signaltest;
signal = signal-0.0161; % Baseline correction

peaka = signal(pas:paf,1);
peakb = signal(pbs:pbf,1);
peakc = signal(pcs:pcf,1);
peakd = signal(pds:pdf,1);
peake = signal(pes:pef,1);

% calculate area under curve
dt = 1;

na = size(peaka,1);
ya = peaka;
% calculate area by adding small areas
da = zeros(na-1,1);
for j=1:na-1
    da(j) = ((ya(j)+ya(j+1))/2) *dt;
end
aa = sum(da);

nb = size(peakb,1);
yb = peakb;
% calculate area by adding small areas
db = zeros(nb-1,1);
for j=1:nb-1
    db(j) = ((yb(j)+yb(j+1))/2) *dt;
end
ab = sum(db);

nc = size(peakc,1);
yc = peakc;
% calculate area by adding small areas
dc = zeros(nc-1,1);
for j=1:nc-1
    dc(j) = ((yc(j)+yc(j+1))/2) *dt;
end
ac = sum(dc);

nd = size(peakd,1);
yd = peakd;
% calculate area by adding small areas
dd = zeros(nd-1,1);
for j=1:nd-1
    dd(j) = ((yd(j)+yd(j+1))/2) *dt;
end
ad = sum(dd);

ne = size(peake,1);
ye = peake;
% calculate area by adding small areas
de = zeros(ne-1,1);
for j=1:ne-1
    de(j) = ((ye(j)+ye(j+1))/2) *dt;
end

ae = sum(de);

plot(signal(:,1))
titlestr = sprintf('Areas: Methanol=%.3f, Ethanol=%.3f, Propanol=%.3f, Butanol=%.3f, Pentanol=%.3f', aa, ab, ac, ad, ae);
title(titlestr)
