Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (45 sloc) 1.55 KB
%% Copyright 2014 MERCIER David
function model_kao(OPTIONS)
%% Function used to calculate the hardness in bilayer sample with
% the model of Kao and Byrne (1981).
gui = guidata(gcf);
x = 1./gui.results.hc;
x = checkValues(x);
t = gui.results.t_corr;
% A(1) = Hf
bilayer_model = @(Hf, x) ...
1e-9*(1e9.*gui.data.Hs + (2 .* gui.config.numerics.k_Kao .* t .* ...
(1e9.*Hf - 1e9.*gui.data.Hs)) .* x);
% Make a starting guess
gui.results.A0 = gui.data.Hf0;
if gui.config.licenceOpt_Flag
[gui.results.Hf_fit, ...
gui.results.resnorm, ...
gui.results.residual, ...
gui.results.exitflag, ...
gui.results.output, ...
gui.results.lambda, ...
gui.results.jacobian] =...
lsqcurvefit(bilayer_model, gui.results.A0, x, ...
gui.results.H, ...
gui.config.numerics.Min_Hardness, ...
gui.config.numerics.Max_Hardness, ...
OPTIONS);
else
model = @LMS;
gui.results.Hf_fit = fminsearch(model, gui.results.A0, OPTIONS);
warning('No Optimization toolbox available !');
end
function [sse, FittedCurve] = LMS(params)
Hf(1) = params(1);
FittedCurve = 1e-9*(1e9.*gui.data.Hs + ...
(2 .* gui.config.numerics.k_Kao .* t .* ...
(1e9.*Hf - 1e9.*gui.data.Hs)) .* x);
gui.results.residual = FittedCurve - gui.results.H;
sse = sum(gui.results.residual .^ 2);
end
gui.results.Hf = 1e-9*(...
1e9.*gui.data.Hs + (2 .* gui.config.numerics.k_Kao .* t .* ...
(1e9.*gui.results.Hf_fit - 1e9.*gui.data.Hs)) .* x);
guidata(gcf, gui);
end
You can’t perform that action at this time.