# Team:Paris/Modeling/More f3 Algo

(Difference between revisions)
 Revision as of 03:44, 30 October 2008 (view source)Hugo (Talk | contribs) (→find_ƒ3 ( FliA ))← Older edit Revision as of 03:45, 30 October 2008 (view source)Hugo (Talk | contribs) (→find_ƒ3 ( FliA ))Newer edit → Line 17: Line 17:

-                                                                                                           function act_pFlhDC = f3(FliA, OmpR)        +                                                                                                            function optimal_parameters = find_f3_FliA(X_data, Y_data, initial_parameters)
-                                                                                                           % activity of pFlhDC in function of OmpR and FliA  +                                                                                                            % gives the 'best parameters' involved in f3 with OmpR = 0 by least-square optimisation
+                                                                                                            % -> USE IT AFTER find_f3_OmpR

-                                                                                                           global beta17 K15 n15 beta22 K6 n6;         +                                                                                                            % X_data = vector of given values of ( [FliA]i ) (experimentally
-                                                                                                           % parameters                                       +                                                                                                            % controled)
+                                                                                                            % Y_data = vector of experimentally measured values f3 corresponding of
+                                                                                                            % the X_data
+                                                                                                            % initial_parameters = values of the parameters proposed by the literature
+                                                                                                            %                       or simply guessed
+                                                                                                            %                    = [beta22, K6 -> (K6)/(coefOmp), n6]

-                                                                                                           act_pFlhDC = ( 1 - hill( OmpR, K15, n15 ) ) * ...                        +                                                                                                            global beta17; % parameter GIVEN BY find_f3_OmpR
-                                                                                                           (beta17 * (1 - hill( FliA, K6, n6)) + beta22 * hill( FliA, K6, n6) );    +
+                                                                                                            function output = act_pFlhDC(parameters, X_data)
+                                                                                                            for k = 1:length(X_data)
+                                                                                                            output(k) = beta17*(1 - hill( X_data(k), parameters(2), parameters(3))) ...
+                                                                                                            + parameters(1)*hill(X_data(k), parameters(2), parameters(3));
+                                                                                                            end
+                                                                                                            end

+                                                                                                            options=optimset('LevenbergMarquardt','on','TolX',1e-10,'MaxFunEvals',1e10,'TolFun',1e-10,'MaxIter',1e4);
+                                                                                                            % options for the function lsqcurvefit
+
+                                                                                                            optimal_parameters = lsqcurvefit( @(parameters, X_data) act_pFlhDC(parameters, X_data), ...
+                                                                                                            initial_parameters, X_data, Y_data, options );
+                                                                                                            % search for the fittest parameters, between 1/10 and 10 times the initial
+                                                                                                            % parameters
+
end                                                                                                                                                      end

## find_ƒ3 ( FliA )

```function optimal_parameters = find_f3_FliA(X_data, Y_data, initial_parameters)
% gives the 'best parameters' involved in f3 with OmpR = 0 by least-square optimisation
% -> USE IT AFTER find_f3_OmpR

% X_data = vector of given values of ( [FliA]i ) (experimentally
% controled)
% Y_data = vector of experimentally measured values f3 corresponding of
% the X_data
% initial_parameters = values of the parameters proposed by the literature
%                       or simply guessed
%                    = [beta22, K6 -> (K6)/(coefOmp), n6]

global beta17; % parameter GIVEN BY find_f3_OmpR

function output = act_pFlhDC(parameters, X_data)
for k = 1:length(X_data)
output(k) = beta17*(1 - hill( X_data(k), parameters(2), parameters(3))) ...
+ parameters(1)*hill(X_data(k), parameters(2), parameters(3));
end
end

options=optimset('LevenbergMarquardt','on','TolX',1e-10,'MaxFunEvals',1e10,'TolFun',1e-10,'MaxIter',1e4);
% options for the function lsqcurvefit

optimal_parameters = lsqcurvefit( @(parameters, X_data) act_pFlhDC(parameters, X_data), ...
initial_parameters, X_data, Y_data, options );
% search for the fittest parameters, between 1/10 and 10 times the initial
% parameters

end
```