MATLAB Answers

How can I fit data to a system of implicit equations?

36 views (last 30 days)
Abdelrhman Mohamed
Abdelrhman Mohamed on 5 Jan 2021
Edited: Matt J on 6 Jan 2021
The goal is to find the best fit for unknown parameters (A1, A2, A3, A4) to fit experimental data to a system of implicit equations
y1 = (A3*(x/(x+A1))*exp(B1*(B2-B3+A4-y1*V1*A2)))
y2 = (A3*(x/(x+A1))*exp(B1*(B2-B3+A4-y2*V2*A2)))
y3 = (A3*(x/(x+A1))*exp(B1*(B2-B3+A4-y3*V3*A2)))
y4 = (A3*(x/(x+A1))*exp(B1*(B2-B3+A4-y4*V4*A2)))
Here
  • x is the independent variable
  • y is the dependent variable.
  • B1, B2 and B3 as well as V1, V2, V3, V4 are known constants
  • A1, A2, A3, and A4 are unknown parameters that I want to use the code to find.
For example:
B1= -40;
B2 = 0.1;
B3 = 0.5;
V1 = 20e-4; V2 = 40e-4, V3 = 60e-4, V4 = 60e-4
x, y1, y2, y3, y4 are experimental data arrays
x = [240;220;195;170;145;120;95;75;50;35;25;12.5;6;0]*1e-6;
y1 = [-1;-0.95;-0.94;-0.90;-0.87;-0.84;-0.77;-0.67;-0.56;-0.48;-0.37;-0.20;-0.13;0];
y2 = [another array, similar format];
y3 = [another array, similar format];
y4 = [another array, similar format];
Note: all four equations have the same format where x is an independent variable, and y is the measured experimental output (dependent variable). One constant is different between the equations (reaction volume: V1, V2, V3 and V4).
Thanks in advance

  0 Comments

Sign in to comment.

Answers (2)

the cyclist
the cyclist on 5 Jan 2021
I'm pretty sure that this is a really tricky problem to solve, and I am not certain it can be done in MATLAB. (When I say this, usually someone posts within 5 minutes with an obvious solution, so I hope that that happens!)
But, I thought I could share some thoughts, and maybe it wlil help.
You might be able to solve this with the fitglm function from the Statistics and Machine Learning Toolbox.
First step, which I think is possible if you take the log of both sides of the equation, is to isolate the x terms and the y terms onto the two sides of the equation.
Next step is to define the custom link function that links the x and y sides of the generalized regression. That's where it gets tricky, I think. If I'm not mistaken the inverse function you'll need is not simple -- I think it might require the Lambert W function.
So, sorry I can't actually write out a simple, straightforward answer. I hope someone else can.

  1 Comment

Abdelrhman Mohamed
Abdelrhman Mohamed on 5 Jan 2021
Hi,
Thanks for the tips! I'll read about using fitglm.
It's difficult to define y as an explicit function of x. To get around that, I used an implicit function definition. I posted a question a couple of days ago where I could fit the parameters to one equation. The tricky part for me is to use the four experimental datasets simultaneously to fit a system of equations.
(https://www.mathworks.com/matlabcentral/answers/708123-how-can-i-fit-experimental-data-to-a-system-of-implicit-equations-using-optimization-toolbox?s_tid=prof_contriblnk)

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by