-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtempCreateFits.m
96 lines (79 loc) · 3.04 KB
/
tempCreateFits.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function [fitresult, gof] = createFits(doy_tmp_2014, sif_daily_2014, gpp_daily_2014, evi_daily_2014)
%CREATEFITS(DOY_TMP_2014,SIF_DAILY_2014,GPP_DAILY_2014,EVI_DAILY_2014)
% Create fits.
%
% Data for 'untitled fit 1' fit:
% X Input : doy_tmp_2014
% Y Output: sif_daily_2014
% Data for 'untitled fit 2' fit:
% X Input : doy_tmp_2014
% Y Output: gpp_daily_2014
% Data for 'untitled fit 4' fit:
% X Input : doy_tmp_2014
% Y Output: evi_daily_2014
% Output:
% fitresult : a cell-array of fit objects representing the fits.
% gof : structure array with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 03-Dec-2015 13:48:06
%% Initialization.
sif_daily_2014(sif_daily_2014>=1.0) = NaN;
% Initialize arrays to store fits and goodness-of-fit.
fitresult = cell( 3, 1 );
gof = struct( 'sse', cell( 3, 1 ), ...
'rsquare', [], 'dfe', [], 'adjrsquare', [], 'rmse', [] );
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( doy_tmp_2014, sif_daily_2014 );
% Set up fittype and options.
ft = fittype( 'a+(b-k*x)*(1/(1+exp(c-d*x))-1/(1+exp(e-f*x)))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [0 0 0 0 0 0 0];
opts.StartPoint = [0.05 0.7 17.25 0.1128 33.1 0.117 0.005];
opts.Upper = [0.2 1 Inf Inf Inf Inf Inf];
% Fit model to data.
[fitresult{1}, gof(1)] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult{1}, xData, yData );
legend( h, 'sif_daily_2014 vs. doy_tmp_2014', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel doy_tmp_2014
ylabel sif_daily_2014
grid on
%% Fit: 'untitled fit 2'.
[xData, yData] = prepareCurveData( doy_tmp_2014, gpp_daily_2014 );
% Set up fittype and options.
ft = fittype( 'a+(b-k*x)*(1/(1+exp(c-d*x))-1/(1+exp(e-f*x)))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [1 15 150 1 270 1 0.005];
% Fit model to data.
[fitresult{2}, gof(2)] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 2' );
h = plot( fitresult{2}, xData, yData );
legend( h, 'gpp_daily_2014 vs. doy_tmp_2014', 'untitled fit 2', 'Location', 'NorthEast' );
% Label axes
xlabel doy_tmp_2014
ylabel gpp_daily_2014
grid on
%% Fit: 'untitled fit 4'.
[xData, yData] = prepareCurveData( doy_tmp_2014, evi_daily_2014 );
% Set up fittype and options.
ft = fittype( 'a+(b-k*x)*(1/(1+exp(c-d*x))-1/(1+exp(e-f*x)))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [0 0 0 0 0 0 0];
opts.StartPoint = [0.3 0.5 150 1 280 1 0.05];
% Fit model to data.
[fitresult{3}, gof(3)] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 4' );
h = plot( fitresult{3}, xData, yData );
legend( h, 'evi_daily_2014 vs. doy_tmp_2014', 'untitled fit 4', 'Location', 'NorthEast' );
% Label axes
xlabel doy_tmp_2014
ylabel evi_daily_2014
grid on