Setting unknown constants in equation for known data
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
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 件のコメント
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!