How can I use fmisearch() to evaluate the parameters in a matrix?

1 visualización (últimos 30 días)
3Nz0
3Nz0 el 30 de Abr. de 2021
Comentada: 3Nz0 el 1 de Mayo de 2021
I have the following equation:
f(t)=integral(g(t,x)*h(x) dx)
I discretized the problems because the symbolic expression can't be evaluate (too complicated), so:
where:
f(t) is a vector length=n;
g(t,x) is a matrix n rows and m columns;
h(x) should be a vector length=m. However it depends on 3 parameters.
I want to determine those 3 parameters such that f(t)-integral()=0.
If the 3 parameters are known I use trapz or Simpson method to evaluate the integral.
Do you know a method to apply fminsearch() to evaluate the 3 parameters?
Thank you in advance

Respuesta aceptada

Star Strider
Star Strider el 30 de Abr. de 2021
If the objective is to determine the parameter at a zero-crossing (root), use fsolve or fzero, not fminsearch.
Try something like this —
g = @(t,x) sin(2*pi*x.*t); % Create Function
h = @(x) exp(x); % Create Function
a = -5; % Define Lower Integration Limit
b = +5; % Define Upper Integration Limit
f = @(t) integral(@(x)g(t,x).*h(x), a, b) % Integral Funciton Call (Objective Fucntion)
f = function_handle with value:
@(t)integral(@(x)g(t,x).*h(x),a,b)
[T,Fval] = fsolve(f, 42) % Estimate Parameter
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
T = 143.2500
Fval = -1.3207e-10
.
  9 comentarios
3Nz0
3Nz0 el 1 de Mayo de 2021
Wow, thank you so much for your help.
In the function definitions there are some errors:
wGEX = @(mw,M0,a,b) 1.9*(((mw./M0).^(a+1)).*exp(-(mw/M0).^b));
G_fcn = @(t,M0,a,b) G0N.*(G(t,M0,a,b)).^beta;
Further:
-I think is better to use P0=[10 3 200000] (initial values near to the final solution).
-maybe, the definition of ObjFcn shoul be chi_squared minimization: ObjFcn = @(p) (1./n_exp).*sum(((G -G_fcnp(p,t)).^2)./(G.^2))
where n_exp is the number of points from experimental data.
but, really, Many Thanks again!!!!!
Star Strider
Star Strider el 1 de Mayo de 2021
As always, my pleasure!
I simply changed the assignments and functions from the provided symbolic code, as best I could.
Even with the revisions, I cannot get it to even come remotely close to fitting ‘G’. If the code is correct, there could be a problems with the constant values or magnitudes.
For the record, the current code is —
G0N=2E5;
Me=18500;
M_star=160000;
k_tdd=1.05E-15;
k_rouse=2E-12;
beta=2.3;
% syms I t mw M0 a b
digits(5)
x = @(t,mw) t./(M_star*k_tdd*(mw.^2));
gx = @(t,mw) -x(t,mw)+sqrt(x(t,mw)).*sqrt(x(t,mw)+(sqrt(pi*x(t,mw)))+pi);
U = @(t,mw) ((1./k_tdd).*(1./(mw.^3)).*t)+(M_star.*gx(t,mw)./mw);
F_sr = @(t,mw) (8/pi^2)*integral(@(I) 1./((2*I-1).^2) .* exp(-(2*I-1).^2 .* U(t,mw)), 1, inf, 'ArrayValued',1);
wGEX = @(mw,M0,a,b) 1.9*(((mw./M0).^(a+1)).*exp(-(mw/M0).^b));
w = @(mw,M0,a,b) wGEX(mw,M0,a,b)./mw;
F_w = @(t,mw,M0,a,b) F_sr(t,mw).*w(mw,M0,a,b);
G = @(t,M0,a,b) integral(@(mw)F_w(t,mw,M0,a,b), 0, inf, 'ArrayValued',1);
G_fcn = @(t,M0,a,b) G0N.*(G(t,M0,a,b)).^beta;
t = [100 50 25 10 5 2.63 1.03 0.526 0.244 0.0991 0.0516 0.0251 0.00996 0.00495 0.00252 0.001 ];
G = [124 879 6110 31900 64000 94400 131000 151000 169000 184000 193000 201000 209000 215000 235000 303000 ];
G_fcnp = @(p,t) G_fcn(t,p(1),p(2),p(3));
ObjFcn = @(p) norm(G - G_fcnp(p,t))
% n_exp = numel(t);
% ObjFcn = @(p) (1./n_exp).*sum(((G -G_fcnp(p,t)).^2)./(G.^2));
P0=[10 3 200000];
ms = MultiStart;
problem = createOptimProblem('fmincon', 'x0',P0, 'objective',ObjFcn);
P = run(ms,problem,250)
% [P,resnorm] = lsqcurvefit(G_fcnp, randn(3,1), t, G)
G_out = G_fcnp(P,t)
figure
plot(t, G, 'p')
hold on
plot(t, G_fcnp(P,t), '-r')
hold off
grid
The estimates for the parameters are —
P =
336.9743 48.8744 369.3595
It does not converge to a successful result with either version of ‘ObjFcn’.

Iniciar sesión para comentar.

Más respuestas (1)

3Nz0
3Nz0 el 1 de Mayo de 2021
I installed the new version of matlab (2021a), but, again, with this version my results are different from your:
MultiStart completed some of the runs from the start points.
6 out of 250 local solver runs converged with a positive local solver exit flag.
P =
10 3 200000
G_out =
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I know that it is a very complicated system, for this reason I discretized the problem (file.txt). The problem is I don't know how to extimate the parameters.
  8 comentarios
Star Strider
Star Strider el 1 de Mayo de 2021
Thank you!
I’ll check those. If I can improve on them, I’ll post back here.
3Nz0
3Nz0 el 1 de Mayo de 2021
The results shoul be:
247300; 11.349; 3.366;
I think there is a problem with the constant c=1.9 in wGEX.
This number is a normalizing parameter and the condition is:
c | integral(wGEX)=1.
The final check is not only between G (experimental data) and G_out, but also between wGEX and the experimental data in the attachment.
The .txt is a MWD I digitized from a paper.
I didn't write this just to "simplify" the problem at the beginning

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by