Good day all
I have this curve (it is a solution of a partial differential equation that am working on)

and I want to calculate numerically the rate of exponential decay but I don't know how to go about it. Is there a way to do this with Matlab? or is there any other way to calculate the rate of exponential decay for it? Any help will be greatly appreciated.
$f(t)$ decaying (or growing) exponentially for all $t > t_0$ means that there are parameters $c,\lambda$ such that $$ f(t) = c\,e^{\lambda (t-t_0)} \text{ for $t > t_0$.} $$
Now put an logarithmic scaled on the $y$-axis, i.e. instead of $f$, we look at the function $$ \hat f(t) = \ln f(t) = \ln c + \ln e^{\lambda(t-t0_0)} = \ln c + \lambda (t-t_0) = \lambda t + \ln c - \lambda t_0 \text{,} $$ which means that $\hat t$ will then be a line with slope $\lambda$.
Thus, you can numerically find the rate of decay by fitting a line to the logarithmn of the samples of $f$ you computed.
If you really want to do non-linear regression (by the look of your curve, linear regression should work quite well!), you can use matlab's
lsqcurvefitfunction. You'll need to provide it with the parametrized objective function you want to fit, and preferrably with it's jacobi matrix (otherwise, the algorithms must resort to numeric differentiation, which is always a bit troublesome). Our objective function is $$ F\left((c,\lambda),t\right) = c\, e^{\lambda t} $$ and has the partial derivatives $$\begin{eqnarray} \frac{\partial F}{\partial c} &=& e^{\lambda t} &\quad& \frac{\partial F}{\partial \lambda} &=& c\lambda e^{\lambda t} \text{.} \end{eqnarray}$$ The following matlab function computes bothYou can then use this with
lsqcurvefitby doingNote that this is mostly off the top of my head, and I haven't actually tried it. So there might be syntax errors and other mistakes in this code.