Setting unknown constants in equation for known data

2 Ansichten (letzte 30 Tage)
shir levi
shir levi am 31 Jul. 2024
Kommentiert: Walter Roberson am 31 Jul. 2024
I have data of points and equation with 3 unknown constants.I want to finds the constants that will give me the values of the data how can i do that ?
  1 Kommentar
Walter Roberson
Walter Roberson am 31 Jul. 2024
Do you have three sets of data to solve for three constants?
Or do you have more sets of data and you want to estimate the three constants to best fit given the data?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Torsten
Torsten am 31 Jul. 2024
Bearbeitet: Torsten am 31 Jul. 2024
how can i do that ?
By solving the system
yi - f(xi,a,b,c) = 0
for a,b and c.
Here, (xi,yi) are your data points.
If f is linear in a, b and c, use "lsqlin", if f is nonlinear in a, b and c, use "lsqnonlin" or "lsqcurvefit".
I assumed that the number of data points is greater than the number of unknown parameters (3).

John D'Errico
John D'Errico am 31 Jul. 2024
Bearbeitet: John D'Errico am 31 Jul. 2024
This is the classic regression problem, either linear or nonlinear, and that depends on how the parameters enter into the "model".
A model like
y = a*x^2 + b*x + c
is linear in the parameters, so it is a "linear" model in terms of estimation. This is the case even though the curve itself is not a straight line. That confuses many new users, since the word "linear" can be used in two different ways.
A model like
y = a+b*exp(c*x)
is nonlinear in the parameters, so nonlinear tools will be necessary.
And there are literally dozens of tools available to solve the problem, depending on the form of that model. For polynomial models, use polyfit. Or you can even use backslash. Or lsqlin.
For nonlinear models, you can use tools from the optimization toolbox, so lsqcurvefit, or lsqnonlin. Or you can use nlinfit from the stats TB. You can even use fminsearch.
And of course, you can find dozens of tools on the file exchange (even some I have posted.)
If you want better help than this, I would first suggest you do some reading about these concepts. Or you need to provide more information about the model. If you do so, it would help if you show your data too, as then someone can give even better help yet.

Community Treasure Hunt

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

Start Hunting!

Translated by