How can I check the parameters at each iteration in fminsearch

6 次查看(过去 30 天)
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 个评论
Saeid Bina
Saeid Bina 2019-11-8
oh! Thank you so much for your great help!
I got them. Although they are a bit confusing but still good progress!
Iteration Func-count min f(x) Procedure
0 1 0.336821
9.1437 0.0699
8.7083 0.0734
1 3 0.336821 initial simplex
9.1437 0.0664
9.3614 0.0629
A little bit difficult to undrestand or export to Excel.
Thank you so much.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by