% Script that reads a multi-column dataset from an Excel file and detects
% the peaks in each column. Returns a 3-dimentional table of results in PP.
D=xlsread('GCMR.xlsx');
DataSize=size(D);
clear PP;
x=D(2:length(D),2); % Because time axis starts in column 2, row 2.
threshold=0.1; % Detects only peaks with heights above this threshold.

for ColumnNumber=3:DataSize(2) % Becasue first y value is in column 3
    y=D(:,ColumnNumber);
%   P=allpeaks(x,y); % Alternative peak finding function
    P=peaksat(x,y,threshold); % Alternative peak finding function
%   P=findpeaksG(x,y,0,0.0017,3,3,2); % Alternative peak finding function
    sizeP=size(P);
    PP(1:sizeP,:,ColumnNumber)=P;
    plot(x,D(2:383,8),'.-')
    disp(['Column number ' num2str(ColumnNumber)])
    disp('      Peak number   Position    Height')
    disp(P)
end

PeakTableSize=size(PP);
clf
plot(x,D(2:383,3:10),'.-')
legend('Column 3','Column 4','Column 5','Column 6','Column 7','Column 8','Column 9','Column 10')
xlabel('time axis column 2 (starts in row 2)')
title('Plots of peaks in multi-column dataset GCMR.xlsx')