Borrar filtros
Borrar filtros

Fitting a function of the form x-a for unknown a

1 visualización (últimos 30 días)
Shawn
Shawn el 3 de Sept. de 2014
Comentada: Shawn el 23 de Sept. de 2014
We have data which is roughly exponential for x<a, and approximately a power law (x-a)^b for x>a, but I'm unclear how (or if it's even possible) to find a adaptively.
Clearly fitting a function of the form Ce^(bx)+ c(x-a)^d is a problem (if for no other reason than the fact that 0<x<a gives complex value), but short of brute force trial and error to find a, I'm not quite sure where to start.
I guess I'm looking to optimize the value of a by simultaneously fitting the exponential below and the power law above until both converge (though I'm pretty sure that's not possible without a fair amount of work).

Respuesta aceptada

Roger Wohlwend
Roger Wohlwend el 4 de Sept. de 2014
Yes, you're looking for an optimization, and I can assure you that it is not a fair amount of work. However it won't work with the function you mention in your question. Instead use the optimization function lsqcurvefit with the following function you want to fit:
function y = myoptfunc(coeff, xdata)
y = NaN(length(xdata),1);
q = xdata < coeff(1);
y(q) = coeff(2) * exp(coeff(3) * xdata(q));
y(~q) = coeff(4) * (xdata(~q) - coeff(1)).^coeff(5);
end
The vector coeff contains your coefficients. The first one is your parameter a.
  1 comentario
Shawn
Shawn el 23 de Sept. de 2014
Cheers, thanks. Sorry for the delay in getting back to this, life intervened! I'll have a play with the method you suggested and see how it goes, it looks generally useful for us for some other types of fitting we need to do as well.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by