# Setting unknown constants in equation for known data

조회 수: 4 (최근 30일)
shir levi 2024년 7월 31일
댓글: Walter Roberson 2024년 7월 31일
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이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Walter Roberson 2024년 7월 31일
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?

댓글을 달려면 로그인하십시오.

### 답변 (2개)

Torsten 2024년 7월 31일
편집: Torsten 2024년 7월 31일
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).
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

John D'Errico 2024년 7월 31일
편집: John D'Errico 2024년 7월 31일
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