フィルターのクリア

Create an equation using curve fitting

1 回表示 (過去 30 日間)
Harjot Singh Saluja
Harjot Singh Saluja 2021 年 4 月 26 日
コメント済み: Star Strider 2021 年 4 月 26 日
Hello,
I have a data set which is as follows:
p = [27.77748384 24.17306411 11.13145056 3.698850278];
t = [791.3080768 763.1277705 616.5766311 448.0010846];
far = [0.022016716 0.020330783 0.012707741 0.011639681];
nox = [28 23.2 10 4.3];
where p,t and far are my inputs which give nox as my output. I want to generate some equation which can predict my nox using the inputs. I will verify the equation with some other but similar data set. I have some sort of constraints and relationships known beforehand, such as nox is proportional to p^n, where n is a constant. Another relationship is nox being proportional to a*exp(t) where a is a constant. My way of doing this is to use the curve fitting toolbox to fit the data, however I don't know how to do this for multiple inputs (p,t and far) along with the specific constraints. Is there some way to do this using the curve fitting toolbox, or some even better way to do it without using the toolbox?
TIA

回答 (1 件)

Star Strider
Star Strider 2021 年 4 月 26 日
The easiest way to do that is to combine all the relevant independent variables into one matrix, then refer to the columns of the matrix inside the objective function.
I have no idea what function to fit to these data, however this approach works (even though the function itself is not a good fit to the data) —
p = [27.77748384 24.17306411 11.13145056 3.698850278];
t = [791.3080768 763.1277705 616.5766311 448.0010846];
far = [0.022016716 0.020330783 0.012707741 0.011639681];
nox = [28 23.2 10 4.3];
x = [p(:) t(:) far(:)]; % Create The 'x' To Combine All 3 Independent Variable Vectors
f = @(b,x) x(:,1).^b(1) + b(2).*exp(x(:,2)) + b(3).*x(:,3) + b(4); % Refer To Various Columns Of 'x' In The Objective Function
[B,fval] = fminsearch(@(b) norm(nox(:) - f(b,x)), rand(4,1)*1E-3)
I have no idea ho ‘far’ is involved here, so I just made it a linear relation.
  2 件のコメント
Harjot Singh Saluja
Harjot Singh Saluja 2021 年 4 月 26 日
The fminsearch does not seem to work. It always reaches the upper limit of either max function evaluations or max iterations, even when I have both of them set to 1e7. Is there any other way?
Star Strider
Star Strider 2021 年 4 月 26 日
Use any optimisation or curve fitting function you want, and preferably the correct objective function. I use fminsearch here simply to demonstrate the approach (and because it is a core MATLAB function, everyone has it).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCurve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by