Can I extract the fully-constructed model from a cfit object, not just the separate pieces of the formula?

1 回表示 (過去 30 日間)
I have a cfit object that I would like to get the full equation from, with parameter values plugged in. All I have been able to find in my searching so far is "coeffvalues" to get an array of parameter values and "formula" to get the general model form. For example, the cfit object is:
General model Exp1:
val(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 3695 (3307, 4083)
b = 9.448e-05 (8.636e-05, 0.0001026)
What I am looking to extract is:
val(x) = 3695*exp(0.00009448*x)
Is this possible?
  2 件のコメント
Steven Lord
Steven Lord 2020 年 9 月 2 日
Note that what you're looking to extract is unlikely to give the same results as evaluating the fit object itself. The values of the coefficients that are displayed may not be exactly the same as the values of the coefficients that are stored and used for computations.
Is a exactly 3695 or is it 3695.0000000001?
Ellen Maas
Ellen Maas 2020 年 9 月 2 日
Yes, I've run into that with Excel. Thank you for pointing it out.

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

採用された回答

Ayush Gupta
Ayush Gupta 2020 年 9 月 2 日
There is no direct way to obtain the equation with the substituted parameter values from the 'cfit' object in Curve Fitting Toolbox. However, there is a workaround, a string representation can be generated of the curve from a cfit object, ‘cfit_object’:
equation = formula(cfit_object); %Formula of fitted equation
parameters = coeffnames(cfit_object); %All the parameter names
values = coeffvalues(cfit_object); %All the parameter values
for i = 1:numel(parameters)
param = parameters{i};
l = length(param);
location = regexp(equation, param); %Location of the parameter within the string
while ~isempty(location)
%Substitute parameter value
equation = [equation(1:location-1) num2str(values(idx)) equation(location+l:end)];
location = regexp(equation, param);
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by