-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppmIt.m
77 lines (64 loc) · 2.79 KB
/
ppmIt.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%%%%%%%%%%%%%%%%%%%%%%% ppmIt to get ppm data %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Find peaks, fit gaussian to peaks (if any) and integrate
% to calcluate area under the curve
function ppm_data = ppmIt(data,x_min,x_max,MinPeakHeight,...
MinPeakDistance, MinPeakWidth,...
data_fit,detector,compound)
if detector == "FID"
ppm_data =[];
for i = 1:numel(data)
if data(i).instrument == "GC/FID" &&...
data(i).MethodName ~= "Warren Short Gas_break.M"
x = data(i).Time;
y = data(i).Signal;
range = x >= x_min & x <= x_max;
x = x(range);
y = y(range);
y_normalised = Y_normalised(x,y);
plot(x,y_normalised);
title(strcat(detector," ",compound));
% Find peaks and integrate to find ppm values
[pks, loc] = findpeaks(y_normalised,'MinPeakHeight',...
MinPeakHeight,...
'MinPeakDistance', MinPeakDistance,...
'MinPeakWidth',MinPeakWidth);
if numel(loc) == 0
ppm_data = [ppm_data; 0];
elseif numel(loc) > 1;
ppm_data = [ppm_data; 0];
elseif numel(loc) == 1
area = GuassFit(x,y_normalised);
ppm_data = [ppm_data; predict(data_fit, area)];
end
end
end
elseif detector == "TCD"
ppm_data =[];
for i = 1:numel(data)
if data(i).instrument == "GC/TCD" &&...
data(i).MethodName ~= "Warren Short Gas_break.M"
x = data(i).Time;
y = data(i).Signal;
range = x >= x_min & x <= x_max;
x = x(range);
y = y(range);
y_normalised = Y_normalised(x,y);
plot(x,y_normalised)
title(strcat(detector," ",compound));
%Find peaks and integrate to find ppm values
[pks, loc] = findpeaks(y_normalised,'MinPeakHeight',...
MinPeakHeight,...
'MinPeakDistance', MinPeakDistance,...
'MinPeakWidth',MinPeakWidth);
if numel(loc) == 0
ppm_data = [ppm_data; 0];
elseif numel(loc) > 1;
ppm_data = [ppm_data; 0];
elseif numel(loc) == 1
x_new = GuassFit(x,y_normalised);
ppm_data = [ppm_data; predict(data_fit, x_new)];
end
end
end
end