How can I find the best curve of a set of curves to fit data points?

2 Ansichten (letzte 30 Tage)
Jdol
Jdol am 28 Feb. 2020
Kommentiert: Jdol am 5 Mär. 2020
This is for modelling a chemical reaction A -> B, though ideally the process could be modified to account for reversible and more complex reactions.
Say I have a set of curves of a=a0 * exp(-kt) where x0 is the initial x value, k is the rate of conversion of A to B, and t is time in an interval (normally about one second). The time interval doesn't vary, and a0 is a value known in advance. Thus, if I run a reaction and gather data on the amount of chemical A, how do I fit curves with varying k values to the data? My thinking was using one of the least squares fit modes in the optimization toolbox, but then the question is which one is best and how do I use it such that it spits out a value for k.
Thanks!

Antworten (2)

dpb
dpb am 28 Feb. 2020
How can there be a question of "which one is best"? You have a physical model and one constant, k, to estimate so a least squares estimate will be the best for that data set.
It's not clear what data you have collected, however...do you have the concentration of A vs t, or only the final concentration at the end of the time interval?
Is it the same reaction with a set of time histories for each or one measurement for a set of different reactants?
So many questions, so few answers... :)
  1 Kommentar
Jdol
Jdol am 28 Feb. 2020
Apologies for me being unclear.
By which model is best, I mean which sounds like it applies to me the most, specifically which least squares solver: nonlinear least squares or nonlinear curve fitting.
The time interval to iterate over is set, as is the initial concentration. What I want to do is to find which value of k best fits the data points (which for an A->B reaction should be exponentially decreasing) for a=a0*exp(-kt). The time and initial amount of A, a0 are set by me in real life, and values of A are determined in the lab. I do have the concentration of A vs. t, but the value of k is unknown.
In this instance, it is the same reaction with time histories.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 28 Feb. 2020
Not sure I know exactly what you want (since you didn't show any pictures, code, or data), but for what it's worth, see my attached code that solves the rate equation with fitnlm().
If you'd rather have an exponential decay rather than the chemical rate equation, I've attached demos for that as well.
  1 Kommentar
Jdol
Jdol am 5 Mär. 2020
Wonderful, thank you so much. I'll try that right now. Apologies for the delay, long week.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Chemistry finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by