How can I check the parameters at each iteration in fminsearch
6 views (last 30 days)
Show older comments
Hello everyone. I am very new in Matlab. I prepared a code that finds the minimum of RMSE to fit a data.
I have one function and also m file that calls function file. And easily trys to find the minimum. Please help me to prepare output file or change the option of fminsearch.
In order to save your time, I have copied my file here:
Thank you so much in advance.
Function File:
function [RMSE,Tfm_ILS] = Tfm_ILS(par,tau,Tfm_mis)
% Detailed explanation goes here
T_0 = 15.96; % undisturbed ground temperature [°C]
C_0 = 4900000;
r_bh = 0.076; % borehole radius [m]
a = par(1)/C_0; % 1st try thermal diffusivity [m2/s]
q = 110.22;
Tfm_ILS = T_0 + (q*par(2))+(q/(4*pi*par(1)))*(-0.5772 + log((4*a*tau)/(r_bh^2)));
RMSE=(sum((Tfm_ILS-Tfm_mis).^2)/length(tau))^0.5;
end
------------------------------------------------
M file is here:
load GHE1_6kW_P12_V1.txt
[min,n]=size(GHE1_6kW_P12_V1);
t_in=60;
t_end=1800;
tau = GHE1_6kW_P12_V1(t_in:t_end,1);
Tfm_mis = GHE1_6kW_P12_V1(t_in:t_end,2);
par = [8.7083, 0.0699];
options= optimset('OutputFcn', @outfun);
[RMSE,Tfm_ILS] = Tfm_ILS(par,tau,Tfm_mis);
[par,RMSE] = fminsearch('Tfm_ILS',par,options,tau,Tfm_mis);
6 Comments
Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!