## This function will solve the Generalized Power Law (GPL) ## and calculate (estimate) the parameters D0,D1 and m ## in the GPL model D(t) = D0 + D1*t^m ## note t = reduced time ## Author: Steph Bredenhann ## Created: 2020-03-14 function [ GPL_RMSE, GPL_RMSE_derivative ] =... fn_BBR_GPL_RMSE( x, D, t ); ## n_max = length(D); ## fprintf('fn_GPL: n_max = %7.1f \n',n_max); D0 = x(1); D1 = x(2); m = x(3); ## Dcalc = fn_GPL_model(D0, D1, m, t); Dcalc = D0 + D1*t.^m; %fprintf('In fn_BBR_GPL_RMSE, D = %7.1f \n',Dcalc); ## Dmeasured ## Dcalc SRE = (D-Dcalc)./D; SRE = SRE.^2; ## D(1) ## Dcalc(1) ## SRE(1) GPL_SSRE = 0; for i = 1:length(SRE) GPL_SSRE = GPL_SSRE + SRE(i); end GPL_RMSE = sqrt(GPL_SSRE/length(GPL_SSRE)); fprintf('fn_GPL: RMSE = %7.5f \n',GPL_RMSE(1)); % determine derivative with respect to reduced time if nargout > 1 % gradient required GPL_RMSE_derivative = D1*m*tr.^(m-1); end end