-
Notifications
You must be signed in to change notification settings - Fork 0
/
fig5_fitRD.m
49 lines (40 loc) · 1.29 KB
/
fig5_fitRD.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
clc
clear
% Unbiased
resArray = dlmread('/data/resourceEfficiencyConcatenated.csv',',',2,0);
resArray = resArray(all(resArray,2),:);
% Repulse
resArray2 = dlmread('/data/repulseConcat.csv',',',2,0);
resArray2 = resArray2(all(resArray2,2),:);
% Attract
resArray3 = dlmread('/data/attractConcat.csv',',',2,0);
resArray3(all(resArray3,2),:);
%% Individual
addpath('/scripts/polyfix/')
% Only plot repulse for figure
for j=2
if j==1
resArray = resArray;
elseif j==2
resArray = resArray2;
elseif j==3
resArray = resArray3;
end
slope = zeros(length(resArray),2);
B = mean(resArray(:,end-4));
for k=1:length(resArray)
distortion = [0.001,.02,.04,.06,.08,.10,.20,.30,.40,.50,.60,.70,.80,.90];
rate = resArray(k,end-13:end);
% plot rate as function of distortion with intersect through (0.5,
% mean(rate_at_50_percent_distortion)
pfit = polyfix(distortion, log10(rate), 1,0.5, log10(B));
f1 = 10.^(polyval(pfit,distortion));
semilogy(distortion,rate, '.', distortion, f1, '-');
xlabel('Distortion','fontsize',12)
ylabel('log_{10}(Resources)','fontsize',12)
hold on
slope(k,2) = pfit(1); % get slope of linear fit
slope(k,1) = resArray(k,1);
end
end
xlim([-0.05 1])