How to fit a log plot to a set of data

1 visualizzazione (ultimi 30 giorni)
I have a vector of pressure data over a certain time period and I have made a plot of the data
using plot(time,pressure)
From the plot, it looks like the line of data is close to a log curve. I want to insert a log fit into my plot. Can this be done in MATLAB?
Thanks

Risposta accettata

Star Strider
Star Strider il 8 Lug 2014
It can be done, but it depends on what you mean by ‘log fit’. Without seeing your data, I can’t suggest an approach.
In the physical sense at least, pressure is not to my knowledge a function of time, but of temperature and volume. That lends itself to a physical model that is likely a better and more appropriate fit to your data than would be modeling it as a function of time.
  2 Commenti
Hail
Hail il 8 Lug 2014
This is my plot. The black line is a 2nd order line of best fit. Instead of a 2nd order line I want to insert a log line (I think its going to be a log)
Star Strider
Star Strider il 8 Lug 2014
If you have a mathematical model of your data of which you want to estimate the parameters, that’s definitely possible.
If you don’t have one, I suggest an asymptotic function such as:
P(t) = Pmax * (1 - exp(K*t))
which as an anonymous function becomes:
P = @(b,t) b(1) .* (1 - exp(b(2).*t));
The reason is that the log function is monotonically increasing (to infinity, which I hope is not what your pressure curve actually does) while the asymptotic function is eventually bounded at Pmax for all t. You can easily fit the function with fminsearch if you don’t have access to the Statistics Toolbox nlinfit function or the Optimization Toolbox lsqcurvefit function.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by