-
Notifications
You must be signed in to change notification settings - Fork 0
/
PIcurves_walkthrough.m
65 lines (49 loc) · 1.75 KB
/
PIcurves_walkthrough.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
clear
%% Photosynthesis-irradiance Curve
%% Get the P-I data
containerdir = ['/Users/Danny/Desktop/CATEGORIES/CAREER_MANAGEMENT/VIMS/'...
'Assistance/Helga_do_Rosario_Gomes/'];
datafile = [containerdir,'PE_Dan2016.csv'];
PIdata = readtable(datafile);
names = {'control', 'Peridinuim', 'Phaeodactylum'};
%% Examine the data
E = PIdata.E;
y1 = PIdata.control_P_;
y2 = PIdata.Peridinuim_P_;
y3 = PIdata.Phaeodactylum_P_;
plotHandles = plot(E,[y1,y2,y3], 'marker','o', 'linestyle','-');
title('Data points')
%% Platt Equation:
% Let's define the parameters in terms of a single variable "x", so that
%
% x(1) = PBs;
% x(2) = alpha;
% x(3) = beta;
%
% Then we'll define the platt curve as a function of the parameter vector
% "x" and the irradiance data, which will enter the function as "xdata"
F = @(x,xdata)x(1) * (1-exp( (-x(2)*xdata)/x(1) ) ) .* exp( (-x(3)*xdata)/x(1) );
% We need to set a starting point for the optimization routine... here we'll
% use PBs=1000, alpha=600, beta = 0.00:
x0 = [1000 100 0.00];
%% Run the solver and plot the resulting fits
co=get(groot,'DefaultAxesColorOrder'); % Get default matlab colors
[x1,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,E,y1);
hold on
plot(E,F(x1,E), 'linestyle','--', 'color',brighten(co(1,:),-0.5));
[x2,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,E,y2);
plot(E,F(x2,E), 'linestyle','--', 'color',brighten(co(2,:),-0.5));
[x3,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,E,y3);
plot(E,F(x3,E), 'linestyle','--', 'color',brighten(co(3,:),-0.5));
legend(plotHandles, names)
%% Print parameters to the command window
format shortG
disp('Parameter estimates of...')
disp({'PBs' , 'alpha', 'beta'})
disp([names{1},':'])
disp(x1)
disp([names{2},':'])
disp(x2)
disp([names{3},':'])
disp(x3)
format short