fsolve + fminbnd combination... Problem !

2 visualizaciones (últimos 30 días)
Sergio Quesada
Sergio Quesada el 5 de Oct. de 2018
Comentada: Torsten el 9 de Oct. de 2018
Good evening to everybody. My problem is the following:
I want to solve a non-linear equation G(r)-(t-texp)=0 for the variable r with the following complications:
- r is in the upper limit of a definite integral of the integrand F(x).
-"texp" is a 1x10 array experimental points.
- t, which is another variable, are the minimums of another function H defined itself by G, H[t, G(r)].
I am not sure about the combination of algorithms that I must use. I have tried this scheme:
x0=ones(1,10)
rteor=@(r,t) fsolve(integral(G(x),1,r)-(t-texp),x0);
t = fminbnd(@(r,t) H,lb,up);
, but it does not work. I am almost sure fsolve is not well written. I have tried to make combinations with arrayfun inside fsolve, but with no success. I think it is a problem of dimensions and/or declaring variables. Can anybody help me please?
Thanks !!!
  2 comentarios
Matt J
Matt J el 5 de Oct. de 2018
Editada: Matt J el 5 de Oct. de 2018
So r is a scalar and t is a function of r through the equation
t(r) = argmin_z H(z,G(r) )
That means you have 10 equations in one unknown, r. How do you expect to satisfy 10 different equations with only 1 degree of freedom?
Or, do you mean you are looking for 10 different r(i), corresponding to each texp(i) separately?
Sergio Quesada
Sergio Quesada el 6 de Oct. de 2018
Editada: Sergio Quesada el 6 de Oct. de 2018
Thank you for your answer, Matt. Yes, r is an scalar, and for each value of r, I want 10 different solutions G(r) - (texp-t) = 0, to be solve, each one for each value of texp. I call these solutions "rteor". I am trying this now:
rteor = @(r,t) fsolve(@(r) arrayfun (@(T) integral(F,1,r)-(T-t),texp), x0)
t = fminbnd(H(r,t),6e-3,t1-5e-5,options);
, with no results

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 5 de Oct. de 2018
Editada: Matt J el 5 de Oct. de 2018
This might be what you want.
G=@(r) integral( @F,1,r);
t=@(r) fminbnd(@(z) H(z,G(r)),lb,up);
for i=1:10
r_solution(i) = fzero(@(r) G(r)-(t(r)-texp(i)) , r0 );
end
  11 comentarios
Sergio Quesada
Sergio Quesada el 9 de Oct. de 2018
Editada: Sergio Quesada el 9 de Oct. de 2018
Yes, Matt. I am continous changing the program because I am trying to solve it. The problem is not muddled at all:
1- I have a collection of experimental points (texp, Iexp) that I want to fit.
2 - The equation I have is not I(t), but I[r_teor(t)], where r_teor(t) is in the form t(r_teor), being "r_teor" in an upper integration limit.
As simple as that. This is my last code tried:
nombre='C2';t0=6.00E-3;FC=4.24E-1;a=6.05;FD=8.17E-4;Io=15.53;V=25;
fID=fopen('Para_Leer_C2_2219_ptos.txt','r');
Columnexpi=1;Columnexpf=10;
formatSpec='%f %f'; sizeSpec=[2,Inf];
datos=fscanf(fID,formatSpec,sizeSpec); close('all');N=Columnexpf-Columnexpi+1;
texp=datos(1, Columnexpi:Columnexpf);Iexp=datos(2, Columnexpi:Columnexpf); t1=texp(1);
F=@(x) FC.*exp(-(V.*a)./(30.*x.*log(x))); part=1e-3;
for i=1:N
t=@(i) (1+(5.*((texp(i)-t0).^0.25)))
r_teor=@(i) fsolve(Int(r)-(t(i)-texp(i)), inpts(i),options);
L=@(r) 1:part:rteor(i);
me=@(r) arrayfun(F,L(r)); ue=@(r) F(max(L(r)));
Int=@(r) part.*(sum(me(r))-(ue(r)./2));
options = optimoptions('fsolve','Display','none');
Ifar=@(i)(FD./FC).*(r_teor(i).*exp((V.*a)./(30.*r_teor(i).*log(r_teor(i)))));
Itrans=@(i) Io./((r_teor(i)).^4);
Itotal=@(i) Ifar(i)+Itrans(i);
SumError=@(i) sum((Itotal(i)-Iexp).^2);
options = optimset('Display','iter','TolX',1e-4,'PlotFcns','@optimplotx');
t= fminbnd(SumError(i),6e-3,t1-5e-5,options);
end
Torsten
Torsten el 9 de Oct. de 2018
And you claim that
2 - The equation I have is not I(t), but I[r_teor(t)], where r_teor(t) is in the form t(r_teor), being "r_teor" in an upper integration limit.
is not muddled ? Nobody is able to understand what you write here.

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by