Define a new fitting function

3 ビュー (過去 30 日間)
Ilaria Pintus
Ilaria Pintus 2019 年 5 月 14 日
コメント済み: Ilaria Pintus 2019 年 5 月 16 日
Hello everyone!
I need to define a new fitting function that is not in the matlab library. I've already tried to use the "fit App" but then I wasn't able to save the function and so re-use it. Now I'm trying in this way but it doesn't work.
model_1 = fittype('a*netOD_red+b*(netOD_red)^3','independent','netOD_red','dependent','dose')
fit_model_1 = fit(netOD_red, dose, model_1)
where my X vector is "netOD_red" and my Y vector is "dose".
The function I want to use is Y= a*X+b*(X)^3
Can someone help me? Thank you
  2 件のコメント
Steven Lord
Steven Lord 2019 年 5 月 14 日
Can you clarify what "it doesn't work" means?
Does MATLAB throw an error? If so what is the full and exact text of the error message you receive -- all the text displayed in red?
Does MATLAB issue a warning? If so what is the full and exact text of the warning message you receive -- all the text displayed in orange?
Does MATLAB give you a different result than you expected? If so can you show us a (small) data set and the code you use to obtain the answer (the code in your original message only shows how you created the fit -- show us how you used that fit to get the numeric result) and explain what you expected?
This information may help us understand what went wrong and/or what you're trying to do.
Ilaria Pintus
Ilaria Pintus 2019 年 5 月 15 日
This is what I obtain in the Command Window:
model_1 =
General model:
model_1(a,b,netOD_red) = a*netOD_red+b*(netOD_red)^3
Error using fit>iFit (line 135)
X must be a matrix with one or two
columns.
Error in fit (line 116)
[fitobj, goodness, output, convmsg]
= iFit( xdatain, ydatain,
fittypeobj, ...
Error in ALL (line 442)
fit_model_1 = fit(netOD_red, dose,
model_1)

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

採用された回答

Steven Lord
Steven Lord 2019 年 5 月 15 日
Is your data stored as row vectors? If so, transpose them (using the .' operator) to be column vectors in your call to fit.
  1 件のコメント
Ilaria Pintus
Ilaria Pintus 2019 年 5 月 16 日
Thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by