Curve fitting triplicate data using matlab

4 views (last 30 days)
Hello,
I am trying to curve fit a triplicate set of data (3 sets) using the following equation. I am attaching the screenshot of the sample data and the equation I will be using to fit. I am trying to fit k1 and k2 here. How should I code this in matlab? Thanks in advance.
Equation: C1/C0 = exp(-k1*T)/2 + (k2)/(k1 + 2*k2) + (k1*exp(-T*(k1 + 2*k2)))/(2*(k1 + 2*k2))
C1/C0 is the dependent variable and T is the independent variable.

Answers (1)

Sachin Lodhi
Sachin Lodhi on 31 Aug 2023
Based on my understanding, it appears that you are interested in curve-fitting triplicate data using MATLAB.
To successfully accomplish this, it would be beneficial to have a basic understanding of creating functions in MATLAB and utilizing the built-in curve fitting functions such as “lsqcurvefit()”. Please refer to the below step-by-step procedure for curve-fitting triplicate data using “lsqcurevefit”:
  1. Define the equation as a function that takes parameters “x” and “T”. This would involve utilizing exponential functions and mathematical operations to create the desired equation.
  2. Load the time array (“T”) and concentration ratio array (“C1_C0”) into MATLAB. These arrays would contain the triplicate data you wish to fit.
  3. Create an initial guess array with the initial values for “k1” and “k2”. These values will serve as starting points for the curve-fitting process.
  4. Utilize the “lsqcurvefit” function to estimate the values of “k1” and “k2”. This requires providing the equation function, initial guess array, “T”, and “C1_C0” as input arguments. The output will be the estimated values for “k1” and “k2”.
I recommend you refer to the following documentation page to know more about “lsqcurvefit” function: Solve nonlinear curve-fitting (data-fitting) problems in least-squares sense - MATLAB lsqcurvefit - MathWorks India
I hope by following these steps, you would be able to curve-fit triplicate data.

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!