-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverage_plot.m
More file actions
105 lines (57 loc) · 2.46 KB
/
Copy pathaverage_plot.m
File metadata and controls
105 lines (57 loc) · 2.46 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function funcOut = average_plot(analyVar, indivDataset, avgDataset)
%%% average_plot.m - Joe Whalen 2017.12.15
%%% Make a plot of the average of any quantity in indivDataset grouped
%%% by the flags in the master batch file.
indVarField = 'imagevcoAtom'; % The Field of an IndivDataset that is to be plotted on the X axis
depVarField = 'sfiIntegral'; % The field of an indivdataset that is to be plotted on the y axis
[xdata, ydata] = getxy(indVarField, depVarField, analyVar, indivDataset, avgDataset);
scanIDs = analyVar.uniqScanList;
x = cell(length(scanIDs));
y = cell(length(scanIDs));
yerr = cell(length(scanIDs));
for id = 1:length(scanIDs)
x{id} = [];
for basename = 1:analyVar.numBasenamesAtom
if scanIDs(id) == analyVar.meanListVar(basename)
x{id} = union(x{id},xdata{basename});
end
end
y{id} = zeros(size(x{id}));
yerr{id} = zeros(size(x{id}));
tempy = zeros(size(analyVar.meanListVar));
for i = 1:length(x{id})
num=0;
for basename = 1:analyVar.numBasenamesAtom
if scanIDs(id) == analyVar.meanListVar(basename)
for j = 1:indivDataset{basename}.CounterAtom
if xdata{basename}(j) == x{id}(i)
num = num + 1;
tempy(num) = ydata{basename}(j);
end
end
end
end
y{id}(i) = mean(tempy(1:num));
yerr{id}(i) = std(tempy(1:num));
end
end
avgDataset.(depVarField) = y;
avgDataset.(strcat(depVarField,'_unc')) = yerr;
avgDataset.(strcat(depVarField,'_x')) = x;
figure;
hold on;
for id = 1:length(scanIDs)
errorbar(x{id}, y{id}, yerr{id},...
'LineStyle','-',...
'Marker', 'o',...
'MarkerSize', analyVar.markerSize,...
'MarkerFaceColor', analyVar.COLORS(id,:),...
'MarkerEdgeColor', 'none',...
'Color', analyVar.COLORS(id,:));
end
legend(num2str(scanIDs))
hold off
funcOut.analyVar = analyVar;
funcOut.indivDataset = indivDataset;
funcOut.avgDataset = avgDataset;
end