Representing a given curve as the sum of an exponential + gaussian curve

1 visualización (últimos 30 días)
Hi,
I have a given curve y(x) which behaves like an exponential curve until a point say x=.25 and then it follows a Gaussian distribution until the end (say x=8.25).
How do I use cfit(or any other method) to fit data into my curve?
My course of action was that split the range of x into 2 parts - part 1- x upto which there is exponential behavior and part 2 - later part of x for which there is a Gaussian nature.
So i found the coefficients for each case respectively(part 1 and part 2 using standard model fits like 'exp1' and 'Gauss1') i.e ( a and b for a*exp(b*x) and a1,b1,c1 for a1*exp(-((x-b1)/c1)^2) ) for different ranges of x (according to the behavior) .
And then used these coefficients in fitting in the cfit tool for my general model a*exp(b*x)+ a1*exp(-((x-b1)/c1)^2) for all range of x . But this does not give me the correct answer(which is obvious).
Basically i need to have a curve which can represent both exponential behavior as well as Gaussian nature using a single equation .How do i do this?
Thank you.

Respuesta aceptada

Matt J
Matt J el 12 de Jul. de 2013
Your model would really be something like this
a*exp(b*x).*(x<=K)+ a1*exp(-((x-b1)/c1)^2).*(x>K)
where K is the transition point separating the two ranges. I think you would have to curve fit each piece separately as you've been doing, but to evaluate the curve using a single expression, you would use the above.
  3 comentarios
Matt J
Matt J el 12 de Jul. de 2013
Well, you have the pieces to build what you want. Suppose you write functions
[error,a,b] = Fit1(x,y)
[error, a1,b1,c1] = Fit2(x,y)
that return parameter estimates and errors using the model from each piece. I'm pretty sure cfit lets you build such functions. Then you could write a 3rd function
function [error,a,a1,b,b1,c1]=Fit3(K,x,y)
I=(x<=K);
[error1,a,b] =Fit1(x(I),y(I))
[error2, a1,b1,c1] = Fit2(x(~I),y(~I));
error=error1+error2;
and finally
Kfit=fminsearch(@(K)Fit3(K,x,y), Kguess);
[~,a,a1,b,b1,c1]=Fit3(Kfit,x,y);
Thejas
Thejas el 12 de Jul. de 2013
Thank you Matt :) That was good

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fit Postprocessing 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